/* ============================================================
   ANDBAS Comenzi – Stylesheet  (responsive v20)
   ============================================================ */

*, *::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;

    --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;
    --topbar-h:          56px;
    --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%);
    padding: 1rem;
}

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

@media (max-width: 480px) {
    .login-container { padding: 1.75rem 1.25rem; }
}

.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; }

/* ── APP 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: 300;
    overflow-y: auto;
    transition: transform .25s ease;
}

.sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.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; }

/* Buton X inchidere sidebar pe mobil */
.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: rgba(255,255,255,.55);
    font-size: 1.4rem;
    cursor: pointer;
    padding: .2rem;
    line-height: 1;
}

.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; }

/* ── TOPBAR (mobil) ── */
.topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--c-sidebar);
    z-index: 200;
    align-items: center;
    padding: 0 1rem;
    gap: .75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.topbar-menu-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    padding: .3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    flex-shrink: 0;
}

.topbar-title { color: #fff; font-weight: 700; font-size: .95rem; flex: 1; }

/* Overlay inchidere sidebar pe mobil */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 290;
}

.sidebar-overlay.open { display: block; }

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

/* ── PAGE HEADER ── */
.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: .75rem;
    flex-wrap: wrap;
    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-header-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
}

.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);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.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(160px, 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 ── */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.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: 160px; }
.filter-select { min-width: 130px; }

.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; -webkit-overflow-scrolling: touch; }

.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; }

.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; }

/* ── FORMS ── */
.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);
}

/* Touch-friendly on mobile */
@media (max-width: 767px) {
    .form-control, .filter-input, .filter-select {
        font-size: 16px; /* previne zoom automat iOS */
        min-height: 44px;
    }
    .filter-input, .filter-select { min-width: 0; width: 100%; }
}

.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.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;
    min-height: 38px;
}

.btn-sm    { padding: .3rem .625rem; font-size: .8125rem; min-height: 32px; }
.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: flex-start; 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: 400;
    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; flex-wrap: wrap; }

/* ── LEGENDA URGENTA ── */
.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; flex-shrink: 0; }

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

.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; }
tr.subcmd .nr-crt-col { color: var(--c-muted); font-weight: 400; }

.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; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ══════════════════════════════════════════════════════════ */

/* ── TABLET (max 1024px) ── */
@media (max-width: 1024px) {
    :root { --sidebar-w: 220px; }

    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }

    .page-body { padding: 1.25rem; }
    .page-header { padding: 1rem 1.25rem; }
}

/* ── MOBIL (max 767px) ── */
@media (max-width: 767px) {

    /* Sidebar devine drawer lateral */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.3);
    }

    .sidebar-close { display: block; }

    /* Topbar vizibil pe mobil */
    .topbar { display: flex; }

    /* Main content fara sidebar, cu spatiu pentru topbar */
    .main-content {
        margin-left: 0;
        padding-top: var(--topbar-h);
    }

    /* Page header */
    .page-header {
        padding: .875rem 1rem;
        position: sticky;
        top: var(--topbar-h);
        flex-direction: column;
        align-items: flex-start;
        gap: .625rem;
    }

    .page-header-actions {
        width: 100%;
    }

    .page-header-actions .btn {
        flex: 1;
        justify-content: center;
        font-size: .8rem;
        padding: .45rem .5rem;
    }

    .page-body { padding: .875rem 1rem; }

    /* Stat grid 2 coloane pe mobil */
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: .625rem; }
    .stat-card { padding: .875rem; gap: .625rem; }
    .stat-value { font-size: 1.25rem; }

    /* Filters full width vertical */
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
        gap: .5rem;
        padding: .875rem 1rem;
    }

    .filters-bar .form-group { width: 100%; }
    .filter-input, .filter-select { width: 100%; min-width: 0; }

    /* Butoane filtru full width */
    .filters-bar .btn { width: 100%; justify-content: center; }

    /* Formular - un camp pe rand */
    .form-row, .form-row-3 { grid-template-columns: 1fr; }

    /* Modals full screen pe mobil */
    .modal-backdrop { padding: 0; align-items: flex-end; }
    .modal {
        max-width: 100%;
        max-height: 95vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    .modal-body   { padding: 1.25rem 1rem; }
    .modal-header { padding: 1rem; }
    .modal-footer { padding: .875rem 1rem; }
    .modal-footer .btn { flex: 1; justify-content: center; }

    /* Butoane actiuni mai mari pentru touch */
    .btn-sm { min-height: 36px; padding: .35rem .6rem; }

    /* Tabele scroll orizontal */
    .table-wrapper { border-radius: 0; }

    /* Page header fara sticky pe mobil (topbar e fixed) */
    .data-table th { position: static; }

    /* Ascunde coloane mai putin importante pe telefon */
    .col-hide-mobile { display: none !important; }

    /* Pagination */
    .pagination { flex-direction: column; align-items: flex-start; gap: .5rem; padding: .75rem 1rem; }
}

/* ── MOBILE MIC (max 400px) ── */
@media (max-width: 400px) {
    .stat-grid { grid-template-columns: 1fr 1fr; gap: .5rem; }
    .stat-card { padding: .75rem .625rem; }
    .stat-value { font-size: 1.1rem; }
    .stat-label { font-size: .7rem; }
    .stat-icon  { width: 36px; height: 36px; font-size: 1rem; }

    .page-header-actions .btn { font-size: .75rem; }
    .action-btns .btn-sm { padding: .3rem .4rem; }
}
