/* ========================================
   RU MAN - CSS Principal
   Modern Sidebar Layout - Retractabil
   ======================================== */

/* === RESET & BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* === Brand Colors — Palette B: Teal + Amber === */
    --primary:        #0891B2;
    --primary-dark:   #0E7490;
    --primary-light:  #22D3EE;
    --primary-bg:     #ECFEFF;
    --primary-border: #A5F3FC;

    --accent:         #F59E0B;
    --accent-dark:    #D97706;
    --accent-bg:      #FFFBEB;
    --accent-border:  #FDE68A;

    --secondary:      #22C55E;
    --secondary-dark: #16A34A;
    --warning:        #F97316;
    --danger:         #EF4444;
    --danger-dark:    #DC2626;

    --dark:           #0C1A2E;
    --text-body:      #334155;
    --gray:           #71717A;
    --light-gray:     #F4F9FA;
    --border:         #E4E4E7;
    --white:          #FFFFFF;

    /* Sidebar */
    --sidebar-width:     260px;
    --sidebar-collapsed: 70px;
    --sidebar-bg:        linear-gradient(180deg, #0C1A2E 0%, #0F172A 100%);
    --sidebar-text:      #E2E8F0;
    --sidebar-hover:     rgba(8, 145, 178, 0.15);
    --sidebar-active:    linear-gradient(135deg, #0891B2 0%, #0E7490 100%);

    /* Typography */
    --font-primary:   'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-secondary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: var(--font-secondary);
    background: var(--light-gray);
    color: var(--text-body);
    line-height: 1.6;
}

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

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: var(--transition);
    z-index: 1000;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

/* Scrollbar styling */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Logo */
.sidebar-logo {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
}

.sidebar-logo-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon-mark {
    font-family: var(--font-secondary);
    font-weight: 800;
    font-size: 18px;
    color: #fff;
    letter-spacing: -.04em;
}

.sidebar-logo-text {
    font-family: var(--font-secondary);
    font-size: 20px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -.03em;
    white-space: nowrap;
    transition: var(--transition);
    display: flex;
    align-items: center;
}

/* Punct accent Amber din logo V3 */
.logo-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    margin-left: 2px;
    margin-bottom: 3px;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-logo {
    justify-content: center;
}

.sidebar.collapsed .sidebar-logo-text {
    opacity: 0;
    width: 0;
}

/* Toggle Button */
.sidebar-toggle {
    position: absolute;
    top: 24px;
    right: -16px;
    width: 32px;
    height: 32px;
    background: var(--white);
    border: 2px solid var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: var(--transition);
    z-index: 1001;
}

.sidebar-toggle:hover {
    background: var(--primary);
    color: var(--white);
    transform: scale(1.1);
}

.sidebar-toggle svg {
    width: 16px;
    height: 16px;
    transition: var(--transition);
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* Navigation */
.sidebar-nav {
    padding: 12px 0;
    flex: 1;
}

.nav-item {
    margin: 2px 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    font-size: 14px;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--white);
}

.nav-link.active {
    background: var(--sidebar-active);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.3);
}

/* .nav-icon și .nav-link-icon sunt aliases */
.nav-icon,
.nav-link-icon {
    font-size: 17px;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
    line-height: 1;
}

.nav-link-text {
    white-space: nowrap;
    transition: var(--transition);
    font-weight: 500;
    font-size: 13.5px;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
}

.sidebar.collapsed .nav-link-text {
    opacity: 0;
    width: 0;
}

/* Submenu — clasele din HTML: .nav-item-submenu, .submenu-items, .submenu-arrow, .submenu-link */
.nav-item-submenu {
    margin: 2px 10px;
}

.nav-item-submenu > .nav-link {
    cursor: pointer;
    user-select: none;
}

.submenu-arrow {
    margin-left: auto;
    flex-shrink: 0;
    transition: transform 0.25s ease;
    opacity: 0.6;
    width: 14px !important;
    height: 14px !important;
}

.nav-item-submenu.open .submenu-arrow {
    transform: rotate(90deg);
}

.submenu-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    padding-left: 14px;
    margin: 0 0 0 2px;
}

.nav-item-submenu.open .submenu-items {
    max-height: 400px;
}

.sidebar.collapsed .submenu-items {
    display: none;
}

.submenu-link {
    padding: 8px 12px !important;
    font-size: 13px !important;
    color: rgba(226, 232, 240, 0.75) !important;
    margin: 1px 0;
}

.submenu-link:hover {
    color: #fff !important;
}

.submenu-link.active {
    color: #fff !important;
    background: rgba(8,145,178,0.2) !important;
    box-shadow: none !important;
}

/* Legacy support */
.nav-item.has-submenu > .nav-link::after { display: none; }
.submenu { max-height: 0; overflow: hidden; }

/* Divider */
.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 12px 16px;
}

/* User Info */
.sidebar-user {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--sidebar-active);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    flex-shrink: 0;
    color: #fff;
}

/* .user-info este containerul de text (flex: 1) */
.user-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    transition: var(--transition);
}

.user-name {
    font-weight: 600;
    font-size: 12.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
}

/* .user-company și .user-role — ambele clasele sunt folosite */
.user-company,
.user-role {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Buton logout */
.user-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    color: rgba(255,255,255,0.45);
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
}

.user-logout:hover {
    background: rgba(239,68,68,0.15);
    color: #fca5a5;
}

.sidebar.collapsed .user-info {
    opacity: 0;
    width: 0;
}

.sidebar.collapsed .user-logout {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

/* Legacy */
.user-details { flex: 1; min-width: 0; }

/* === MAIN CONTENT === */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    transition: var(--transition);
    min-height: 100vh;
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* Top Bar */
.top-bar {
    background: var(--white);
    padding: 16px 32px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
}

.top-bar-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Content */
.content {
    padding: 32px;
}

/* === CARDS === */
.card {
    background: var(--white);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
}

/* === STATS GRID === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-left: 4px solid var(--primary);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.stat-card.blue   { border-left-color: var(--primary);   background: linear-gradient(135deg, var(--primary-bg) 0%, #ffffff 100%); }
.stat-card.green  { border-left-color: var(--secondary); background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%); }
.stat-card.yellow { border-left-color: var(--accent);    background: linear-gradient(135deg, var(--accent-bg) 0%, #ffffff 100%); }
.stat-card.red    { border-left-color: var(--danger);    background: linear-gradient(135deg, #fee2e2 0%, #ffffff 100%); }

.stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    color: var(--gray);
    font-size: 14px;
    font-weight: 500;
}

.stat-icon {
    font-size: 22px;
    margin-bottom: 10px;
    line-height: 1;
}

.stat-link {
    display: inline-block;
    margin-top: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    opacity: 0.75;
    transition: var(--transition);
}
.stat-link:hover { opacity: 1; text-decoration: underline; }

/* Dark mode stat cards */
[data-theme="dark"] .stat-card.blue   { background: linear-gradient(135deg, rgba(8,145,178,0.12) 0%, #1E293B 100%); }
[data-theme="dark"] .stat-card.green  { background: linear-gradient(135deg, rgba(16,185,129,0.10) 0%, #1E293B 100%); }
[data-theme="dark"] .stat-card.yellow { background: linear-gradient(135deg, rgba(245,158,11,0.10) 0%, #1E293B 100%); }
[data-theme="dark"] .stat-card.red    { background: linear-gradient(135deg, rgba(239,68,68,0.10)  0%, #1E293B 100%); }

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary);
    color: var(--white);
    text-decoration: none;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.3);
}

.btn-secondary {
    background: var(--secondary);
}

.btn-secondary:hover {
    background: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-warning {
    background: var(--warning);
}

.btn-warning:hover {
    background: #d97706;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* === FORMS === */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
    font-size: 14px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.12);
}

/* === TABLES === */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

thead th {
    background: var(--light-gray);
    padding: 14px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--gray);
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
}

tbody td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--light-gray);
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background: var(--light-gray);
}

/* === ALERTS === */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10B981;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #EF4444;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid #F59E0B;
}

.alert-info {
    background: var(--primary-bg);   /* #ECFEFF */
    color: #164E63;                  /* contrast 7.1:1 pe #ECFEFF ✓ WCAG AA */
    border-left: 4px solid var(--primary);
}

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: var(--primary-bg); color: #164E63; } /* contrast 7.1:1 ✓ */
.badge-gray { background: #f3f4f6; color: #374151; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.collapsed.mobile-open {
        transform: translateX(0);
        width: 280px;
    }
    
    /* Force expanded state on mobile */
    .sidebar.mobile-open .sidebar-logo-text,
    .sidebar.mobile-open .nav-link-text {
        opacity: 1 !important;
        width: auto !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }
    
    .content {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .top-bar {
        padding: 12px 20px;
    }
    
    .mobile-menu-toggle {
        display: flex !important;
    }
    
    .sidebar-toggle {
        display: none;
    }
}

@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none !important;
    }
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.mobile-menu-toggle:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

/* === UTILITIES === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.p-4 { padding: 1rem; }
.flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }

/* === SIDEBAR OVERLAY (MOBILE) === */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

@media (max-width: 768px) {
    .sidebar-overlay {
        display: block;
    }
}

/* === DASHBOARD RESPONSIVE GRIDS === */
@media (max-width: 1024px) {
    /* Row 2: cereri pending + pontaj */
    .dash-row-2 { grid-template-columns: 1fr !important; }
    /* Row 3: angajati recenti + actiuni rapide */
    .dash-row-3 { grid-template-columns: 1fr !important; }
}

/* === MOBILE LOGO === */
.mobile-logo {
    display: none !important;
}

@media (max-width: 768px) {
    .mobile-logo {
        display: flex !important;
        margin-left: auto;
        margin-right: auto;
    }
    
    .top-bar {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 12px;
    }
    
    .top-bar-actions {
        margin-left: 0;
    }
}

/* ============================================================
   TRIAL BADGE
   ============================================================ */
.trial-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(245,158,11,0.12);
    border: 1px solid rgba(245,158,11,0.3);
    color: #D97706;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

/* ============================================================
   THEME TOGGLE BUTTON
   ============================================================ */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--gray);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.theme-toggle:hover {
    background: var(--light-gray);
    color: var(--dark);
}
/* Icon swap: show moon in light mode, sun in dark mode */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ============================================================
   DARK MODE  —  [data-theme="dark"]
   ============================================================ */
[data-theme="dark"] {
    --white:      #1E293B;
    --light-gray: #0F172A;
    --dark:       #F1F5F9;
    --border:     rgba(255,255,255,0.08);
    --gray:       #94A3B8;
    --text-muted: #64748B;
}

[data-theme="dark"] body {
    background: #0F172A;
    color: #CBD5E1;
}

/* Top Bar */
[data-theme="dark"] .top-bar {
    background: #1E293B;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    box-shadow: none;
}
[data-theme="dark"] .theme-toggle:hover {
    background: rgba(255,255,255,0.06);
    color: #F1F5F9;
}

/* Cards */
[data-theme="dark"] .card {
    background: #1E293B;
    border-color: rgba(255,255,255,0.06);
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
[data-theme="dark"] .card-header {
    border-bottom-color: rgba(255,255,255,0.06);
    color: #F1F5F9;
}
[data-theme="dark"] .card-title {
    color: #F1F5F9;
}

/* Typography */
[data-theme="dark"] .page-title,
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4 {
    color: #F1F5F9;
}
[data-theme="dark"] .page-header {
    border-bottom-color: rgba(255,255,255,0.06);
}

/* Forms */
[data-theme="dark"] .form-label {
    color: #94A3B8;
}
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: #253047;
    border-color: rgba(255,255,255,0.1);
    color: #CBD5E1;
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background: #2D3E5A;
    border-color: var(--primary);
    color: #F1F5F9;
}
[data-theme="dark"] .form-control::placeholder {
    color: #64748B;
}

/* Tables */
[data-theme="dark"] .table th {
    background: #253047;
    color: #94A3B8;
    border-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .table td {
    border-color: rgba(255,255,255,0.04);
    color: #CBD5E1;
}
[data-theme="dark"] .table tr:hover td {
    background: rgba(255,255,255,0.03);
}

/* Stat cards */
[data-theme="dark"] .stat-card {
    background: #1E293B;
    border-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .stat-value { color: #F1F5F9; }
[data-theme="dark"] .stat-label { color: #94A3B8; }

/* App footer */
[data-theme="dark"] #app-footer {
    background: #1E293B !important;
    border-top-color: rgba(255,255,255,0.06) !important;
    color: #64748B !important;
}
[data-theme="dark"] #app-footer a {
    color: #94A3B8 !important;
}