/* =============================================================================
   NASTURIA - Stiluri principale
   Mobile-first · Pedrini brand (galben + verde) · Industrial/utilitarian
   ============================================================================= */

/* ---------- VARIABILE GLOBALE ---------- */
:root {
    /* Branding Pedrini - aproximativ, ajustabil */
    --c-yellow:        #F4C800;
    --c-yellow-dark:   #D4A800;
    --c-yellow-light:  #FFF3B0;
    --c-green:         #5CA34C;
    --c-green-dark:    #3F7A33;
    --c-green-light:   #D9EBD3;

    /* Neutrals */
    --c-bg:            #FAFAFA;
    --c-surface:       #FFFFFF;
    --c-text:          #1F2937;
    --c-text-muted:    #6B7280;
    --c-border:        #E5E7EB;
    --c-border-strong: #CBD5E0;

    /* Semantic */
    --c-success:       #16A34A;
    --c-warning:       #F59E0B;
    --c-danger:        #DC2626;
    --c-info:          #2563EB;

    /* Sidebar */
    --c-sidebar-bg:    #1F2937;
    --c-sidebar-text:  #E5E7EB;
    --c-sidebar-muted: #9CA3AF;
    --c-sidebar-hover: #374151;
    --c-sidebar-active: var(--c-yellow);

    /* Spacing scale */
    --s-1: 0.25rem;
    --s-2: 0.5rem;
    --s-3: 0.75rem;
    --s-4: 1rem;
    --s-5: 1.5rem;
    --s-6: 2rem;
    --s-8: 3rem;

    /* Layout */
    --sidebar-w:    240px;
    --header-h:     56px;
    --radius:       6px;
    --radius-lg:    10px;

    /* Shadows */
    --shadow-sm:  0 1px 2px rgba(0,0,0,.05);
    --shadow:     0 2px 6px rgba(0,0,0,.08);
    --shadow-lg:  0 8px 24px rgba(0,0,0,.12);

    /* Tipografie */
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
}

/* ---------- RESET ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    color: var(--c-text);
    background: var(--c-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--c-info); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font: inherit; }

img { max-width: 100%; height: auto; display: block; }

/* Focus accesibilizat */
:focus-visible {
    outline: 2px solid var(--c-yellow-dark);
    outline-offset: 2px;
}

/* ============================================================================
   PAGINA DE LOGIN (fără sidebar)
   ============================================================================ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--s-4);
    background:
        radial-gradient(ellipse at top, var(--c-yellow-light) 0%, transparent 50%),
        radial-gradient(ellipse at bottom, var(--c-green-light) 0%, transparent 50%),
        var(--c-bg);
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    padding: var(--s-6) var(--s-5);
    box-shadow: var(--shadow-lg);
    border-top: 4px solid var(--c-yellow);
}

.login-card h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--s-1);
    letter-spacing: -0.02em;
}

.login-card .subtitle {
    color: var(--c-text-muted);
    font-size: 0.875rem;
    margin-bottom: var(--s-5);
}

.login-card form { display: flex; flex-direction: column; gap: var(--s-4); }

.login-card label {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--c-text);
}

.login-card input[type=text],
.login-card input[type=password] {
    padding: var(--s-3) var(--s-4);
    border: 1.5px solid var(--c-border-strong);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--c-surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.login-card input:focus {
    outline: none;
    border-color: var(--c-yellow-dark);
    box-shadow: 0 0 0 3px var(--c-yellow-light);
}

/* ============================================================================
   ALERTE / MESAJE
   ============================================================================ */

.alert {
    padding: var(--s-3) var(--s-4);
    border-radius: var(--radius);
    border-left: 4px solid;
    margin-bottom: var(--s-4);
    font-size: 0.9375rem;
}

.alert-error,
.alert-danger {
    background: #FEF2F2;
    color: #991B1B;
    border-left-color: var(--c-danger);
}

.alert-success {
    background: #F0FDF4;
    color: #14532D;
    border-left-color: var(--c-success);
}

.alert-warning {
    background: #FFFBEB;
    color: #92400E;
    border-left-color: var(--c-warning);
}

.alert-info {
    background: #EFF6FF;
    color: #1E40AF;
    border-left-color: var(--c-info);
}

/* ============================================================================
   BUTOANE
   ============================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    padding: var(--s-3) var(--s-5);
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9375rem;
    text-decoration: none;
    border: 1.5px solid transparent;
    transition: transform 0.05s, box-shadow 0.15s, background 0.15s;
    user-select: none;
    min-height: 44px; /* touch target */
}

.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--c-yellow);
    color: #1F2937;
    border-color: var(--c-yellow-dark);
}
.btn-primary:hover { background: var(--c-yellow-dark); }

.btn-success {
    background: var(--c-green);
    color: white;
    border-color: var(--c-green-dark);
}
.btn-success:hover { background: var(--c-green-dark); }

.btn-secondary {
    background: var(--c-surface);
    color: var(--c-text);
    border-color: var(--c-border-strong);
}
.btn-secondary:hover { background: #F3F4F6; }

.btn-danger {
    background: var(--c-danger);
    color: white;
    border-color: #B91C1C;
}
.btn-danger:hover { background: #B91C1C; }

.btn-block { width: 100%; }

/* ============================================================================
   LAYOUT PRINCIPAL CU SIDEBAR
   ============================================================================ */

.sidebar-toggle {
    display: none; /* doar pe mobile */
    position: fixed;
    top: var(--s-3);
    left: var(--s-3);
    z-index: 1001;
    width: 44px;
    height: 44px;
    background: var(--c-sidebar-bg);
    border-radius: var(--radius);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    box-shadow: var(--shadow);
}

.sidebar-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: transform 0.2s;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--c-sidebar-bg);
    color: var(--c-sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
}

.sidebar-header {
    padding: var(--s-5) var(--s-4);
    border-bottom: 1px solid var(--c-sidebar-hover);
}

.sidebar-header .logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--c-yellow);
}

.sidebar-header .company {
    font-size: 0.75rem;
    color: var(--c-sidebar-muted);
    margin-top: var(--s-1);
}

.sidebar-nav {
    flex: 1;
    padding: var(--s-3) 0;
    overflow-y: auto;
}

.nav-section {
    padding: var(--s-4) var(--s-4) var(--s-2);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--c-sidebar-muted);
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    color: var(--c-sidebar-text);
    text-decoration: none;
    font-size: 0.9375rem;
    border-left: 3px solid transparent;
    transition: background 0.1s;
}

.nav-item:hover:not(.disabled) {
    background: var(--c-sidebar-hover);
    text-decoration: none;
}

.nav-item.active {
    background: var(--c-sidebar-hover);
    border-left-color: var(--c-yellow);
    color: var(--c-yellow);
    font-weight: 600;
}

.nav-item.disabled {
    color: var(--c-sidebar-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

.nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    opacity: 0.85;
}

.sidebar-footer {
    padding: var(--s-4);
    border-top: 1px solid var(--c-sidebar-hover);
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
}

.user-info { font-size: 0.8125rem; }
.user-name { font-weight: 600; color: var(--c-sidebar-text); }
.user-role {
    color: var(--c-sidebar-muted);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.btn-logout {
    display: block;
    text-align: center;
    padding: var(--s-2) var(--s-3);
    background: var(--c-sidebar-hover);
    color: var(--c-sidebar-text);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
}

.btn-logout:hover {
    background: var(--c-danger);
    color: white;
    text-decoration: none;
}

.main-content {
    margin-left: var(--sidebar-w);
    padding: var(--s-5);
    min-height: 100vh;
}

/* ============================================================================
   CONȚINUT PAGINI
   ============================================================================ */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--s-3);
    margin-bottom: var(--s-5);
    padding: var(--s-5) 0 var(--s-4);
    margin-top: calc(-1 * var(--s-5));
    border-bottom: 1px solid var(--c-border);
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--c-bg);
    box-shadow: 0 2px 4px -2px rgba(0,0,0,0.04);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--c-text-muted);
    font-size: 0.875rem;
    margin-top: var(--s-1);
}

.card {
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--c-border);
    padding: var(--s-5);
    box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: var(--s-4); }

.card-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: var(--s-3);
}

/* Stat tiles pentru dashboard */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--s-4);
    margin-bottom: var(--s-5);
}

.stat-card {
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--c-border);
    padding: var(--s-4);
    border-top: 3px solid var(--c-yellow);
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--c-text-muted);
    font-weight: 600;
    margin-bottom: var(--s-2);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.stat-meta {
    margin-top: var(--s-2);
    font-size: 0.8125rem;
    color: var(--c-text-muted);
}

/* Tabele */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
}

/* Wrapper pentru tabele cu thead sticky - fără overflow pe el (sticky să meargă cu viewport) */
.table-wrapper-sticky {
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
    /* fără overflow-x ca să nu strice sticky thead */
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--c-surface);
}

th, td {
    padding: var(--s-3) var(--s-4);
    text-align: left;
    border-bottom: 1px solid var(--c-border);
}

th {
    background: #F9FAFB;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--c-text-muted);
    font-weight: 600;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFAFA; }

.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-mono   { font-family: var(--font-mono); }
.text-muted  { color: var(--c-text-muted); }

.tabular { font-variant-numeric: tabular-nums; }

/* ============================================================================
   FORMULARE
   ============================================================================ */

.form-group {
    margin-bottom: var(--s-4);
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: var(--s-2);
    color: var(--c-text);
}

.form-control {
    width: 100%;
    padding: var(--s-3) var(--s-4);
    border: 1.5px solid var(--c-border-strong);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--c-surface);
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--c-yellow-dark);
    box-shadow: 0 0 0 3px var(--c-yellow-light);
}

.form-actions {
    display: flex;
    gap: var(--s-3);
    flex-wrap: wrap;
    margin-top: var(--s-5);
}

/* ============================================================================
   RESPONSIVE - Mobile
   ============================================================================ */

@media (max-width: 768px) {
    .sidebar-toggle { display: flex; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease-out;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: calc(var(--header-h) + var(--s-3)) var(--s-3) var(--s-5);
    }

    /* Pe mobil page-header e sticky sub butonul hamburger */
    .page-header {
        top: var(--header-h);
        margin-top: calc(-1 * var(--s-3));
        padding: var(--s-3) 0;
    }

    .page-title { font-size: 1.25rem; }

    .login-card { padding: var(--s-5) var(--s-4); }
    .login-card h1 { font-size: 1.625rem; }
}

/* Print style minimal */
@media print {
    .sidebar, .sidebar-toggle, .btn-logout, .form-actions, .no-print { display: none !important; }
    .main-content { margin-left: 0; padding: 0; }
    body { background: white; }
    .page-header { position: static; }
}

/* Page header e deja sticky default. Clasa .sticky-top păstrată ca alias. */
.page-header.sticky-top { /* backward-compat */ }

/* === SIDEBAR DROPDOWN GROUP === */
.nav-group {
    margin: 0;
}
.nav-group > summary {
    list-style: none;
    cursor: pointer;
}
.nav-group > summary::-webkit-details-marker {
    display: none;
}
.nav-parent {
    display: flex !important;
    align-items: center;
}
.nav-arrow {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.2s;
    color: var(--c-sidebar-muted);
}
.nav-group[open] > summary .nav-arrow {
    transform: rotate(180deg);
}
.nav-child {
    padding-left: 2.75rem !important;
    font-size: 0.85rem;
}
.nav-child .nav-label {
    color: var(--c-sidebar-muted);
}
.nav-child:hover .nav-label,
.nav-child.active .nav-label {
    color: var(--c-sidebar-text);
}

/* === BARĂ STICKY UNICĂ (cu titlu+filtre) === */
.page-control-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--c-bg);
    padding: 1rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--c-border);
    box-shadow: 0 2px 4px -2px rgba(0,0,0,0.06);
}

@media (max-width: 768px) {
    .page-control-bar {
        top: var(--header-h);
    }
}

/* Header de tabel sticky - top-ul se calculează prin JS */
table thead.sticky-thead th {
    position: sticky;
    z-index: 30;
    background: #F9FAFB;
    box-shadow: inset 0 -1px 0 var(--c-border);
}
/* =============================================================================
   ADIȚII LA main.css - componente noi pentru module
   Append acest cod la sfârșitul main.css
   ============================================================================= */

/* ---------- BADGES ---------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.5;
}
.badge-success  { background: var(--c-green-light); color: var(--c-green-dark); }
.badge-warning  { background: #FEF3C7; color: #92400E; }
.badge-danger   { background: #FEE2E2; color: #991B1B; }
.badge-info     { background: #DBEAFE; color: #1E40AF; }
.badge-muted    { background: #F3F4F6; color: var(--c-text-muted); }
.badge-internal { background: var(--c-yellow-light); color: var(--c-yellow-dark); margin-left: var(--s-2); }

/* ---------- FILTER BAR ---------- */
.filter-bar {
    display: flex;
    gap: var(--s-3);
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: var(--s-4);
    padding: var(--s-3);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
}
.filter-bar .form-control {
    margin: 0;
    min-height: 40px;
    padding: var(--s-2) var(--s-3);
}

/* ---------- CHECKBOX LABEL ---------- */
.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: var(--s-2);
    flex-direction: row !important;
    cursor: pointer;
    user-select: none;
}
.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--c-yellow-dark);
}

/* ---------- LINK STIL BUTON-LITE ---------- */
.btn-link {
    color: var(--c-info);
    font-weight: 600;
    font-size: 0.875rem;
}
.btn-link:hover { text-decoration: underline; }

/* ---------- HELP TEXT SUB INPUT-URI ---------- */
.form-group small.text-muted {
    display: block;
    margin-top: var(--s-1);
    font-size: 0.8125rem;
    color: var(--c-text-muted);
}

/* ---------- TABEL HOVER MAI VIZIBIL ---------- */
table tbody tr:hover td {
    background: var(--c-yellow-light);
    transition: background 0.1s;
}

/* ---------- AJUSTARE TEXTAREA ---------- */
textarea.form-control {
    resize: vertical;
    min-height: 80px;
    font-family: var(--font-body);
}