/* ============================================================
   ANDBAS Comenzi – Stylesheet
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --c-bg:          #f0f2f5;
    --c-surface:     #ffffff;
    --c-sidebar:     #1a2332;
    --c-sidebar-hover: #243044;
    --c-sidebar-active: #2d6ef7;
    --c-primary:     #2d6ef7;
    --c-primary-d:   #1a56d6;
    --c-text:        #1a1f36;
    --c-muted:       #6b7280;
    --c-border:      #e5e7eb;
    --c-success:     #059669;
    --c-warning:     #d97706;
    --c-danger:      #dc2626;
    --c-info:        #0891b2;

    /* urgenta culori randuri */
    --row-depasit:   #fef2f2;
    --row-critic:    #fffbeb;
    --row-atentie:   #eff6ff;
    --row-ok:        #f0fdf4;

    --radius:        8px;
    --radius-lg:     12px;
    --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg:     0 4px 16px rgba(0,0,0,.10);
    --sidebar-w:     240px;
    --font:          'Inter', system-ui, sans-serif;
}

body {
    font-family: var(--font);
    background: var(--c-bg);
    color: var(--c-text);
    font-size: 14px;
    line-height: 1.5;
}

/* ── LOGIN ── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a2332 0%, #2d6ef7 100%);
}

.login-container {
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--c-text); }
.login-logo p  { color: var(--c-muted); font-size: .875rem; margin-top: .25rem; }

/* ── LAYOUT ── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--c-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand h2 {
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -.01em;
}

.sidebar-brand p {
    color: rgba(255,255,255,.45);
    font-size: .75rem;
    margin-top: .2rem;
}

.sidebar-nav {
    flex: 1;
    padding: .75rem 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .625rem 1.25rem;
    color: rgba(255,255,255,.65);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .15s;
}

.sidebar-nav a:hover {
    background: var(--c-sidebar-hover);
    color: #fff;
}

.sidebar-nav a.active {
    background: rgba(45,110,247,.18);
    color: #fff;
    border-left-color: var(--c-primary);
}

.sidebar-nav .nav-icon { font-size: 1rem; width: 1.25rem; text-align: center; }

.sidebar-section {
    padding: .25rem 1.25rem;
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: rgba(255,255,255,.28);
    margin-top: .5rem;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-footer .user-info {
    color: rgba(255,255,255,.65);
    font-size: .8125rem;
    margin-bottom: .5rem;
}

.sidebar-footer .user-name {
    color: #fff;
    font-weight: 600;
}

.sidebar-footer a {
    color: rgba(255,255,255,.45);
    text-decoration: none;
    font-size: .8125rem;
    display: flex;
    align-items: center;
    gap: .375rem;
}

.sidebar-footer a:hover { color: #fff; }

/* ── MAIN CONTENT ── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.page-header {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    padding: 1.25rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-header h1 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--c-text);
}

.page-header .breadcrumb {
    font-size: .8125rem;
    color: var(--c-muted);
    margin-top: .125rem;
}

.page-body {
    padding: 1.5rem 1.75rem;
    flex: 1;
}

/* ── CARDS ── */
.card {
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--c-border);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-title {
    font-size: .9375rem;
    font-weight: 600;
}

.card-body { padding: 1.25rem; }

/* ── STAT CARDS ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--c-border);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #eff6ff; }
.stat-icon.green  { background: #f0fdf4; }
.stat-icon.yellow { background: #fffbeb; }
.stat-icon.red    { background: #fef2f2; }

.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .75rem; color: var(--c-muted); margin-top: .125rem; }

/* ── CHARTS GRID ── */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } }

.chart-container { position: relative; height: 220px; }

/* ── FILTERS BAR ── */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .625rem;
    align-items: flex-end;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--c-border);
    background: #fafbfc;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.filters-bar .form-group { margin: 0; }
.filters-bar label { display: block; font-size: .75rem; font-weight: 500; color: var(--c-muted); margin-bottom: .25rem; }

.filter-input, .filter-select {
    height: 36px;
    padding: 0 .625rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font-size: .8125rem;
    font-family: var(--font);
    color: var(--c-text);
    background: #fff;
}

.filter-input { min-width: 180px; }
.filter-select { min-width: 140px; }

.filter-input:focus, .filter-select:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(45,110,247,.12);
}

/* ── TABLE ── */
.table-wrapper { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8125rem;
}

.data-table th {
    background: #f8f9fa;
    padding: .625rem .75rem;
    text-align: left;
    font-weight: 600;
    font-size: .75rem;
    letter-spacing: .02em;
    color: var(--c-muted);
    border-bottom: 1px solid var(--c-border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.data-table td {
    padding: .625rem .75rem;
    border-bottom: 1px solid var(--c-border);
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

/* Row urgenta culori */
.data-table tr.urgenta-depasit td { background: var(--row-depasit); }
.data-table tr.urgenta-critic  td { background: var(--row-critic);  }
.data-table tr.urgenta-atentie td { background: var(--row-atentie); }
.data-table tr.urgenta-ok      td { background: var(--row-ok);      }

.data-table tr:hover td { filter: brightness(.97); }

/* Zile ramase pill */
.zile-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .2rem .55rem;
    border-radius: 99px;
    font-weight: 700;
    font-size: .8rem;
    min-width: 44px;
}

.urgenta-depasit .zile-pill { background: #fca5a5; color: #7f1d1d; }
.urgenta-critic  .zile-pill { background: #fcd34d; color: #78350f; }
.urgenta-atentie .zile-pill { background: #93c5fd; color: #1e3a8a; }
.urgenta-ok      .zile-pill { background: #6ee7b7; color: #064e3b; }

/* ── BADGES STATUS ── */
.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-turnat    { background: #e0e7ff; color: #3730a3; }
.badge-pregatire { background: #fef3c7; color: #92400e; }
.badge-gata      { background: #d1fae5; color: #065f46; }
.badge-livrat    { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.badge-anulat    { background: #fee2e2; color: #991b1b; }

/* ── FORM STYLES ── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .8125rem; font-weight: 500; margin-bottom: .375rem; }

.form-control {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font-size: .875rem;
    font-family: var(--font);
    color: var(--c-text);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(45,110,247,.12);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    white-space: nowrap;
}

.btn-sm { padding: .3rem .625rem; font-size: .8125rem; }
.btn-block { width: 100%; justify-content: center; }

.btn-primary   { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn-primary:hover { background: var(--c-primary-d); border-color: var(--c-primary-d); }

.btn-success   { background: #059669; color: #fff; border-color: #059669; }
.btn-success:hover { background: #047857; }

.btn-danger    { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }

.btn-secondary { background: #fff; color: var(--c-text); border-color: var(--c-border); }
.btn-secondary:hover { background: #f3f4f6; }

.btn-ghost { background: transparent; color: var(--c-primary); border-color: transparent; }
.btn-ghost:hover { background: #eff6ff; }

/* ── ALERTS ── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .875rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── MODAL ── */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-backdrop.open { display: flex; }

.modal {
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title { font-size: 1rem; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--c-muted);
    padding: .25rem;
    border-radius: var(--radius);
    line-height: 1;
}

.modal-close:hover { background: #f3f4f6; color: var(--c-text); }

.modal-body   { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--c-border);
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
}

/* ── LEGEND ── */
.urgenta-legenda {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: .75rem;
    color: var(--c-muted);
    padding: .625rem 1.25rem;
    border-top: 1px solid var(--c-border);
    align-items: center;
}

.legenda-item {
    display: flex;
    align-items: center;
    gap: .375rem;
}

.legenda-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
}

.dot-depasit { background: #fca5a5; }
.dot-critic  { background: #fcd34d; }
.dot-atentie { background: #93c5fd; }
.dot-ok      { background: #6ee7b7; }

/* ── TABLE ACTIONS ── */
.action-btns { display: flex; gap: .375rem; }

/* ── PAGINATION ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .875rem 1.25rem;
    border-top: 1px solid var(--c-border);
    font-size: .8125rem;
    color: var(--c-muted);
}

.page-btns { display: flex; gap: .375rem; }

.page-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    cursor: pointer;
    background: #fff;
    font-size: .8125rem;
    font-family: var(--font);
    transition: all .15s;
    text-decoration: none;
    color: var(--c-text);
}

.page-btn:hover   { background: #f3f4f6; }
.page-btn.active  { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ── UTILS ── */
.text-muted  { color: var(--c-muted); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.fw-bold     { font-weight: 700; }
.mb-1        { margin-bottom: .5rem; }
.mb-2        { margin-bottom: 1rem; }
.mb-3        { margin-bottom: 1.5rem; }
.mt-auto     { margin-top: auto; }
.flex        { display: flex; }
.gap-2       { gap: .5rem; }
.gap-3       { gap: .75rem; }
.align-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap   { flex-wrap: wrap; }

.nr-crt-col { font-weight: 600; color: var(--c-primary); white-space: nowrap; }
.produs-col { max-width: 300px; }
.produs-col .produs-text { font-weight: 500; }

/* Row subcomanda (fara nr_crt) */
tr.subcmd .nr-crt-col { color: var(--c-muted); font-weight: 400; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--c-muted);
}

.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state h3 { font-size: 1rem; color: var(--c-text); margin-bottom: .375rem; }
