/* --- DESIGN SYSTEM & RESET GLOBAL --- */
*, *::before, *::after { box-sizing: border-box; }

:root {
    /* Spacing System */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-xxl: 48px;

    /* Light Theme Palette (Clean & Bright) */
    --bg-body: #f8fafc;
    --bg-sidebar: #ffffff;
    --card-bg: #ffffff;
    --primary: #0f172a;       /* Midnight Indigo Light */
    --primary-light: #475569;
    --accent: #0f9d8d;        /* Darker Teal for better contrast with white text */
    --accent-hover: #0d9488;
    --text-main: #0f172a;
    --text-muted: #475569;    /* Darker gray for better readability */
    
    /* Semantic Colors */
    --danger: #dc2626;        /* Darker Red */
    --danger-bg: rgba(220, 38, 38, 0.1);
    --success: #059669;       /* Darker Green */
    --success-bg: rgba(5, 150, 105, 0.1);
    --warning: #ea580c;       /* Darker Orange */
    --warning-bg: rgba(234, 88, 12, 0.1);
    
    --border: #e2e8f0;
    --input-bg: #f1f5f9;
    --btn-text: #ffffff;      /* White text for buttons in light mode */
    
    /* Fine Floating Elevations */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
    --shadow-floating: 0 25px 50px -12px rgba(0, 0, 0, 0.15);

    --sidebar-active: #0f172a; 
    --sidebar-active-text: #ffffff;
    --edu-bg: rgba(20, 184, 166, 0.05); 
    --edu-border: rgba(20, 184, 166, 0.2);
}

[data-theme="dark"] {
    /* Midnight Indigo Dark Palette */
    --bg-body: #0b0f19;
    --bg-sidebar: #0f172a;
    --card-bg: #1e293b;
    
    --primary: #f8fafc;
    --primary-light: #94a3b8;
    --accent: #0f9d8d;        /* Deep, calm Teal instead of neon */
    --accent-hover: #0d9488;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;    /* Softer, darker gray for less strain */
    
    /* Semantic Colors */
    --danger: #dc2626;        /* Deep Red */
    --danger-bg: rgba(220, 38, 38, 0.15);
    --success: #059669;       /* Deep Green */
    --success-bg: rgba(5, 150, 105, 0.15);
    --warning: #ea580c;       /* Deep Orange */
    --warning-bg: rgba(234, 88, 12, 0.15);
    
    --border: #334155;
    --input-bg: #0f172a;
    --btn-text: #ffffff;      /* White text looks elegant and clear on deep colors */
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    --shadow-floating: 0 25px 50px -12px rgba(0, 0, 0, 0.5);

    --sidebar-active: #0f9d8d; 
    --sidebar-active-text: #ffffff;
    --edu-bg: rgba(15, 157, 141, 0.15); 
    --edu-border: rgba(15, 157, 141, 0.3);
}

body { 
    font-family: 'Inter', system-ui, -apple-system, sans-serif; 
    background-color: var(--bg-body); 
    color: var(--text-main); 
    margin: 0; 
    display: flex; 
    height: 100svh; 
    overflow: hidden; 
    transition: background-color 0.3s ease, color 0.3s ease; 
}

/* --- SIDEBAR (DESKTOP) --- */
.sidebar { 
    width: 260px; 
    background: var(--bg-sidebar); 
    border-right: 1px solid var(--border); 
    display: flex; 
    flex-direction: column; 
    padding: var(--space-lg) var(--space-md); 
    z-index: 100; 
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s; 
    position: relative;
}
.sidebar-header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    margin-bottom: var(--space-xl);
}
.brand { 
    display: flex; 
    align-items: center; 
    gap: var(--space-sm); 
    font-size: 1.4rem; 
    font-weight: 800; 
    color: var(--text-main); 
    text-decoration: none; 
    overflow: hidden; 
    white-space: nowrap;
}
.brand img { 
    width: 32px; 
    height: 32px; 
    border-radius: var(--space-sm);
}

.btn-toggle-sidebar { 
    background: var(--input-bg); 
    border: 1px solid var(--border); 
    color: var(--text-muted); 
    width: 32px; 
    height: 32px; 
    border-radius: var(--space-sm); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    transition: all 0.2s ease; 
    flex-shrink: 0;
}
.btn-toggle-sidebar:hover, .btn-toggle-sidebar:focus { 
    background: var(--card-bg); 
    color: var(--accent); 
    outline: none;
    box-shadow: 0 0 0 2px var(--edu-border);
}
.btn-toggle-sidebar svg { 
    width: 16px; 
    height: 16px; 
    stroke: currentColor; 
    fill: none; 
    stroke-width: 2; 
    transition: transform 0.3s;
}

.nav-menu { 
    display: flex; 
    flex-direction: column; 
    gap: var(--space-sm); 
    flex: 1; 
    overflow: visible;
}
.nav-item { 
    display: flex; 
    align-items: center; 
    gap: var(--space-md); 
    padding: 12px var(--space-md); 
    border-radius: 12px; 
    color: var(--text-muted); 
    text-decoration: none; 
    font-weight: 600; 
    font-size: 0.95rem; 
    transition: all 0.2s ease; 
    cursor: pointer; 
    position: relative; 
    white-space: nowrap;
}
.nav-item svg { 
    width: 20px; 
    height: 20px; 
    stroke: currentColor; 
    fill: none; 
    stroke-width: 2.2; 
    flex-shrink: 0;
}
.nav-item:hover, .nav-item:focus { 
    color: var(--text-main); 
    background: var(--input-bg); 
    outline: none;
}
.nav-item.active { 
    background: var(--sidebar-active); 
    color: var(--sidebar-active-text); 
    box-shadow: var(--shadow-sm);
}
.nav-item:active {
    transform: scale(0.98);
}

.sidebar-footer { 
    border-top: 1px solid var(--border); 
    padding-top: var(--space-lg); 
    display: flex; 
    flex-direction: column; 
    gap: var(--space-sm); 
    overflow: visible;
}
.btn-side-action { 
    display: flex; 
    align-items: center; 
    gap: var(--space-md); 
    width: 100%; 
    padding: 12px var(--space-md); 
    border-radius: 12px; 
    font-size: 0.85rem; 
    font-weight: 600; 
    cursor: pointer; 
    transition: all 0.2s ease; 
    border: 1px solid var(--border); 
    background: var(--card-bg); 
    color: var(--text-main); 
    position: relative; 
    white-space: nowrap;
}
.btn-side-action svg { 
    width: 18px; 
    height: 18px; 
    stroke: currentColor; 
    fill: none; 
    stroke-width: 2; 
    flex-shrink: 0;
}
.btn-side-action:hover, .btn-side-action:focus { 
    border-color: var(--accent); 
    background: var(--input-bg);
    color: var(--accent);
    outline: none;
}
.btn-side-action:active {
    transform: scale(0.98);
}

/* LOGICĂ SIDEBAR MINIMIZAT (DESKTOP) */
.sidebar.collapsed { width: 84px; padding: var(--space-lg) 12px; align-items: center;}
.sidebar.collapsed .sidebar-header { flex-direction: column; gap: var(--space-lg); }
.sidebar.collapsed .brand span { display: none; }
.sidebar.collapsed .btn-toggle-sidebar svg { transform: rotate(180deg); }
.sidebar.collapsed .nav-menu, .sidebar.collapsed .sidebar-footer { align-items: center; }
.sidebar.collapsed .legal-links { display: none; }

.sidebar.collapsed .nav-item, .sidebar.collapsed .btn-side-action { 
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; padding: 0; position: relative; 
    overflow: visible; border-radius: 12px; z-index: 1;
    background: transparent !important; 
}
.sidebar.collapsed .nav-item::before, .sidebar.collapsed .btn-side-action::before {
    content: ''; position: absolute; top: 0; left: 0;
    height: 100%; width: 100%; border-radius: 12px; z-index: -1;
    transition: background 0.2s, box-shadow 0.2s, border 0.2s;
    background: transparent; border: 1px solid transparent;
}
.sidebar.collapsed .nav-item.active::before { background: var(--sidebar-active); }
@media (hover: hover) {
    .sidebar.collapsed .nav-item:hover::before, .sidebar.collapsed .btn-side-action:hover::before {
        background: var(--card-bg); border: 1px solid var(--border); 
    }
    .sidebar.collapsed .nav-item.active:hover::before { background: var(--sidebar-active); border-color: transparent;}
}

.sidebar.collapsed .nav-item span.nav-text, .sidebar.collapsed .btn-side-action span.nav-text {
    position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%) translateX(-5px);
    background: var(--primary); color: var(--bg-body) !important; padding: 6px 10px; border-radius: 8px;
    font-size: 0.75rem; font-weight: 600; white-space: nowrap; pointer-events: none;
    opacity: 0; transition: all 0.2s ease; z-index: 100; box-shadow: var(--shadow-sm);
}
.sidebar.collapsed .nav-item span.nav-text::before, .sidebar.collapsed .btn-side-action span.nav-text::before {
    content: ''; position: absolute; right: 100%; top: 50%; transform: translateY(-50%);
    border-width: 5px; border-style: solid; border-color: transparent var(--primary) transparent transparent;
}

@media (hover: hover) {
    .sidebar.collapsed .nav-item:hover span.nav-text, .sidebar.collapsed .btn-side-action:hover span.nav-text { 
        opacity: 1; transform: translateY(-50%) translateX(0); 
    }
    .sidebar.collapsed .nav-item:hover, .sidebar.collapsed .btn-side-action:hover { z-index: 1000; }
}

/* --- MAIN AREA --- */
.main-wrapper { 
    flex: 1; 
    min-width: 0; /* Prevents flex child from overflowing viewport */
    display: flex; 
    flex-direction: column; 
    height: 100svh; 
    overflow-y: auto; 
    overflow-x: hidden; /* Prevent horizontal scrollbars */
    scroll-behavior: smooth; 
    position: relative; 
    background: var(--bg-body);
}
.top-header { 
    display: flex; 
    justify-content: flex-end; 
    align-items: center; 
    padding: var(--space-md) clamp(var(--space-lg), 4%, var(--space-xxl)); 
    position: sticky; 
    top: 0; 
    background: rgba(var(--bg-body), 0.85); 
    backdrop-filter: blur(12px); 
    -webkit-backdrop-filter: blur(12px);
    z-index: 90;
    border-bottom: 1px solid transparent;
    transition: border-bottom 0.3s;
}
.sidebar.collapsed ~ .main-wrapper .top-header {
    justify-content: space-between;
}
.top-header.scrolled {
    border-bottom: 1px solid var(--border);
}
.header-left { display: none; align-items: center; gap: var(--space-md); min-width: 0; flex: 1; }
.sidebar.collapsed ~ .main-wrapper .header-left { display: flex; }

.page-icon-box { 
    width: 44px; 
    height: 44px; 
    background: var(--card-bg); 
    border: 1px solid var(--border); 
    border-radius: 12px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    color: var(--accent); 
    box-shadow: var(--shadow-sm); 
    flex-shrink: 0;
}
.page-icon-box svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2.2; }
.top-header h1 { 
    margin: 0; 
    font-size: 1.5rem; 
    font-weight: 800; 
    color: var(--text-main); 
    white-space: nowrap; 
    letter-spacing: -0.5px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions { display: flex; align-items: center; gap: var(--space-sm); }

.icon-btn { 
    display: flex; align-items: center; justify-content: center; padding: 0; 
    width: 44px; height: 44px; border-radius: 12px; background: var(--card-bg); border: 1px solid var(--border); color: var(--text-muted); 
    cursor: pointer; transition: all 0.2s ease; 
    position: relative; overflow: visible; text-decoration: none; flex-shrink: 0;
}
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;}
.icon-btn span { 
    position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(-5px);
    background: var(--primary); color: var(--bg-body); padding: 6px 10px; border-radius: 8px;
    font-size: 0.75rem; font-weight: 600; white-space: nowrap; pointer-events: none;
    opacity: 0; transition: all 0.2s ease; z-index: 100; box-shadow: var(--shadow-sm);
}
.icon-btn span::before {
    content: ''; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    border-width: 5px; border-style: solid; border-color: transparent transparent var(--primary) transparent;
}
@media (hover: hover) {
    .icon-btn:hover { border-color: var(--accent); color: var(--accent); outline: none; }
    .icon-btn:hover span { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.profile-btn { 
    display: flex; align-items: center; gap: 10px; padding: 6px 16px 6px 6px; 
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 50px; 
    cursor: pointer; transition: all 0.2s ease; flex-shrink: 0;
}
.profile-btn:hover, .profile-btn:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--edu-bg);}
.profile-btn:active { transform: scale(0.98); }
.profile-avatar { width: 32px; height: 32px; background: var(--accent); color: var(--bg-sidebar); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.95rem; overflow: hidden;}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-weight: 600; font-size: 0.9rem; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px;}

@media (min-width: 769px) and (max-width: 1024px) {
    .profile-name { display: none; }
    .profile-btn { padding: 6px; }
    .top-header { padding: var(--space-md) var(--space-lg); }
}

.btn-info { 
    background: var(--edu-bg); color: var(--accent); border: 1px solid var(--edu-border); 
    width: 24px; height: 24px; border-radius: 50%; font-weight: 800; font-size: 0.8rem; 
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer; 
    margin-left: 10px; flex-shrink: 0; transition: all 0.2s ease;
}
.btn-info:hover { background: var(--accent); color: white; transform: scale(1.1); }

/* --- DASHBOARD CONTENT (Grid) --- */
.dashboard-content { 
    padding: var(--space-lg) clamp(var(--space-lg), 4%, var(--space-xxl)) var(--space-xxl) clamp(var(--space-lg), 4%, var(--space-xxl)); 
    width: 100%; max-width: 1600px; margin: 0 auto; 
}
.page-view { 
    display: none; grid-template-columns: repeat(12, 1fr); gap: var(--space-lg); 
    animation: fadein 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.page-view.active { display: grid; }

.widget { 
    background: var(--card-bg); border-radius: 24px; border: 1px solid var(--border); 
    padding: clamp(16px, 3vw, var(--space-lg)); box-shadow: var(--shadow); display: flex; flex-direction: column; 
    width: 100%; overflow: hidden; min-width: 0; transition: box-shadow 0.3s ease;
    container-type: inline-size;
    container-name: widgetContainer;
}
.widget:hover { box-shadow: var(--shadow-lg); }

.widget-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: var(--space-lg); flex-wrap: nowrap; gap: 10px;}
.widget-header h2 { margin: 0; font-size: clamp(1rem, 2vw + 0.5rem, 1.15rem); font-weight: 700; color: var(--text-main); letter-spacing: -0.3px; flex: 1;}
.w-12 { grid-column: span 12; } .w-8 { grid-column: span 8; } .w-6 { grid-column: span 6; } .w-4 { grid-column: span 4; }

/* Forms & Inputs */
.form-group { margin-bottom: var(--space-md); display: flex; flex-direction: column; width: 100%;}
label { margin-bottom: 8px; font-weight: 600; font-size: 0.85rem; color: var(--text-muted);}
input, select, textarea { 
    width: 100%; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; 
    font-size: 0.95rem; background: var(--input-bg); color: var(--text-main); 
    font-family: 'Inter', system-ui, sans-serif; transition: all 0.2s ease;
    min-height: 44px; /* Touch target size */
}
input:hover, select:hover { border-color: var(--primary-light); }
input:focus, select:focus, textarea:focus { 
    outline: none; border-color: var(--accent); background: var(--card-bg); 
    box-shadow: 0 0 0 4px var(--edu-bg);
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    padding-right: 40px;
}
[data-theme="dark"] select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}

.form-row { display: flex; gap: var(--space-md); flex-wrap: wrap; width: 100%;}
.form-row > * { flex: 1 1 200px; } 

.form-grid { 
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-md); 
    align-items: end; background: var(--input-bg); padding: var(--space-lg); border-radius: 16px; width: 100%; border: 1px solid var(--border);
}
.form-grid .form-group { margin-bottom: 0; }
.form-grid button { height: 46px; } 

.btn-primary-form { 
    width: 100%; padding: 14px; background: var(--accent); color: var(--btn-text); border: none; 
    border-radius: 12px; font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: all 0.2s ease; 
    display: flex; justify-content: center; align-items: center; min-height: 44px;
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.2);
}
.btn-primary-form:hover, .btn-primary-form:focus {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(20, 184, 166, 0.3);
    outline: none;
}
.btn-primary-form:active { transform: translateY(0); }

.btn-small { padding: 10px 16px; font-size: 0.85rem; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--btn-text); white-space: nowrap; transition: all 0.2s ease; min-height: 44px;}
.btn-small:hover { transform: translateY(-1px); }
.btn-danger { background: var(--danger); }
.btn-neutral { background: var(--input-bg); color: var(--text-main); border: 1px solid var(--border); }
.btn-neutral:hover { background: var(--border); }

/* --- DATA GRID (Fluid Layout) --- */
.data-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    width: 100%;
}
.data-card {
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: clamp(12px, 2vw, 16px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
    transition: all 0.2s ease;
}
.data-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}
.data-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}
.data-info strong {
    font-size: clamp(0.9rem, 1.5vw + 0.5rem, 0.95rem);
    color: var(--text-main);
    word-break: break-word;
    white-space: normal;
}
.data-label-mobile {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}
.data-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-shrink: 0;
}
.data-value {
    font-weight: 700;
    font-size: clamp(0.95rem, 1.5vw + 0.5rem, 1.05rem);
    color: var(--text-main);
}
.summary-card {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: clamp(12px, 2vw, 16px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-md);
    font-weight: 700;
    font-size: clamp(0.95rem, 1.5vw + 0.5rem, 1.1rem);
}

/* Mini Action Icons */
.btn-action-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s ease;
}
.btn-action-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.btn-action-icon.edit:hover { background: var(--input-bg); color: var(--accent); }
.btn-action-icon.delete:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* KPIs */
.kpi-grid { grid-column: span 12; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-lg); }
.kpi-card { 
    background: var(--card-bg); border-radius: 20px; border: 1px solid var(--border); 
    padding: var(--space-lg); box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.kpi-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.kpi-value { font-size: clamp(1.5rem, 3vw + 0.5rem, 2rem); font-weight: 800; color: var(--text-main); margin-top: 12px; word-break: break-word; letter-spacing: -1px;}
.kpi-label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;}

.progress-bar { width: 100%; height: 8px; background: var(--border); border-radius: 10px; overflow: hidden; margin-top: 12px;}
.progress-fill { height: 100%; background: var(--accent); transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);}
.canvas-container { position: relative; width: 100%; height: 280px; display: flex; align-items: center; justify-content: center;}

/* --- MODALS --- */
.modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100vw; height: 100dvh; 
    background: rgba(15, 23, 42, 0.7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    z-index: 9999; display: flex; align-items: center; justify-content: center; 
    opacity: 0; pointer-events: none; transition: 0.3s ease; padding: var(--space-md);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-card { 
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 24px; 
    width: 100%; max-width: 550px; padding: var(--space-xl); box-shadow: var(--shadow-floating); 
    position: relative; max-height: 90vh; overflow-y: auto;
    transform: translateY(20px) scale(0.95); transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-overlay.active .modal-card { transform: translateY(0) scale(1); }

/* --- STILURI TUTORIAL & HIGHLIGHT --- */
#tutorialOverlay { background: transparent; backdrop-filter: none; align-items: flex-end; justify-content: flex-end; padding: var(--space-lg); pointer-events: none; }
#tutorialOverlay.active { pointer-events: all; }
#tutorialOverlay .modal-card { width: 400px; max-width: 100%; margin: 0; border: 2px solid var(--accent); box-shadow: var(--shadow-floating); }

.tut-highlight {
    position: relative; z-index: 10000 !important; 
    box-shadow: 0 0 0 4px var(--accent), var(--shadow-floating) !important;
    transition: all 0.3s ease; background: var(--card-bg); border-radius: 24px;
}

.chat-bubble { 
    background: var(--input-bg); padding: var(--space-md) var(--space-lg); 
    border-radius: 0 16px 16px 16px; font-size: 1rem; color: var(--text-main); 
    margin-bottom: var(--space-lg); border-left: 4px solid var(--accent); line-height: 1.6;
}

.wiz-controls { display: flex; justify-content: space-between; margin-top: var(--space-xl); border-top: 1px solid var(--border); padding-top: var(--space-lg); gap: var(--space-md);}
.btn-wiz-next { background: var(--accent); color: white; border: none; padding: 14px 24px; border-radius: 12px; font-weight: 600; cursor: pointer; text-align: center; flex: 1; max-width: 250px; transition: all 0.2s;}
.btn-wiz-next:hover { background: var(--accent-hover); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);}
.btn-wiz-prev { background: transparent; color: var(--text-muted); border: none; font-weight: 600; cursor: pointer; padding: 14px; transition: color 0.2s;}
.btn-wiz-prev:hover { color: var(--text-main); }

.dynamic-row { display: flex; gap: var(--space-sm); margin-bottom: var(--space-sm); align-items: center; width: 100%; flex-wrap: wrap;}
.dynamic-row > input, .dynamic-row > select { flex: 1 1 120px; min-width: 0; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text-main);}
.dynamic-row > button { padding: 12px 16px; flex-shrink: 0; height: 46px;}

@keyframes fadein { from {opacity: 0; transform: translateY(10px);} to {opacity: 1; transform: translateY(0);} }
@keyframes slideInRight { from {opacity: 0; transform: translateX(30px);} to {opacity: 1; transform: translateX(0);} }
@keyframes slideInLeft { from {opacity: 0; transform: translateX(-30px);} to {opacity: 1; transform: translateX(0);} }

.page-view.active.slide-right { animation: slideInRight 0.3s cubic-bezier(0.25, 1, 0.5, 1) forwards; }
.page-view.active.slide-left { animation: slideInLeft 0.3s cubic-bezier(0.25, 1, 0.5, 1) forwards; }

/* TOAST MODERN */
#toast { 
    visibility: hidden; 
    background: var(--primary); 
    color: var(--bg-body); 
    text-align: center; 
    border-radius: 50px; 
    padding: 14px 28px; 
    position: fixed; 
    z-index: 10000; 
    left: 50%; 
    bottom: 30px; 
    transform: translateX(-50%) translateY(20px); 
    font-weight: 600; 
    font-size: 0.95rem; 
    box-shadow: var(--shadow-floating);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 10px;
}
#toast.show { 
    visibility: visible; 
    opacity: 1;
    transform: translateX(-50%) translateY(0); 
}
#toast.toast-error { background: var(--danger); color: white;}
#toast.toast-success { background: var(--success); color: white;}
#toast.toast-info { background: var(--accent); color: white;}
#toast.toast-warning { background: var(--warning); color: white;}

#toast svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
}

.mobile-only { display: none !important; }

/* MOBILE SPECIFIC & BOTTOM NAVIGATION */
@media (max-width: 768px) {
    body { padding-bottom: 70px; /* Space for bottom nav */ }
    
    /* Ascundem Sidebar-ul lateral complet pe mobil */
    .sidebar { display: none !important; }
    .mobile-only { display: flex !important; }
    
    /* Bottom Navigation Bar Nativ cu Glassmorphism */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: rgba(255, 255, 255, 0.75);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        touch-action: none; /* Previne scroll/gesturi native în timpul scrubbing-ului */
        border-top: 1px solid rgba(226, 232, 240, 0.4);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        padding: 8px 10px;
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    }
    
    [data-theme="dark"] .bottom-nav {
        background: rgba(15, 23, 42, 0.75);
        border-top: 1px solid rgba(51, 65, 85, 0.4);
    }
    
    .nav-indicator {
        position: absolute;
        top: 8px;
        left: 0;
        height: calc(100% - 8px - env(safe-area-inset-bottom));
        transform: translateX(var(--tx, 0px)) scale(1);
        transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.25s ease, box-shadow 0.25s ease, border 0.25s ease, scale 0.25s ease;
        background: rgba(0, 0, 0, 0.04);
        backdrop-filter: blur(12px) saturate(180%);
        -webkit-backdrop-filter: blur(12px) saturate(180%);
        border: 1px solid transparent;
        box-shadow: none;
        border-radius: 12px;
        z-index: 0;
    }
    
    [data-theme="dark"] .nav-indicator {
        background: rgba(255, 255, 255, 0.02);
    }
    
    .nav-indicator.is-active {
        transform: translateX(var(--tx, 0px)) scale(1.15);
        background: linear-gradient(135deg, rgba(0, 0, 0, 0.08) 0%, rgba(0, 0, 0, 0.03) 100%);
        border: 1px solid rgba(0, 0, 0, 0.15);
        box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.8), 0 4px 12px rgba(0, 0, 0, 0.12);
    }

    [data-theme="dark"] .nav-indicator.is-active {
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.3);
        box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.3), 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    .nav-indicator.is-dragging {
        transition: none !important; /* Urmărește instantaneu degetul */
    }

    .bottom-nav-item {
        z-index: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 0.7rem;
        font-weight: 600;
        padding: 8px;
        border-radius: 12px;
        transition: all 0.2s ease;
        min-width: 60px;
    }
    
    .bottom-nav-item svg {
        width: 24px;
        height: 24px;
        stroke: currentColor;
        fill: none;
        stroke-width: 2;
        transition: transform 0.2s ease;
    }
    
    .bottom-nav-item.active {
        color: var(--accent);
    }
    .bottom-nav-item.active svg,
    .bottom-nav-item.is-hovered svg {
        transform: translateY(-2px) scale(1.15);
        stroke-width: 2.5;
    }
    
    /* Header Architecture */
    .top-header { padding: 16px 16px; gap: 8px; flex-wrap: nowrap; justify-content: flex-end; }
    .header-left { display: none !important; }
    .top-header h1 { font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    
    .icon-btn span, .profile-name { display: none; } /* Hide text on mobile for compact header */
    .header-actions { gap: 4px; flex-shrink: 0; }
    
    /* Strict Circular Header Buttons */
    .icon-btn, .profile-btn { 
        width: 36px !important; 
        height: 36px !important; 
        min-height: 36px !important; 
        max-width: 36px !important; 
        padding: 0 !important; 
        border-radius: 50% !important; 
        justify-content: center; 
        align-items: center; 
        border: none !important;
        background: transparent !important;
    }
    .icon-btn { background: var(--input-bg) !important; }
    .icon-btn svg { width: 18px; height: 18px; }
    .profile-avatar { width: 36px; height: 36px; font-size: 1rem; }
    
    /* Strict Circular Info Buttons */
    .btn-info {
        width: 32px !important;
        height: 32px !important;
        min-height: 32px !important;
        max-height: 32px !important;
        font-size: 1rem;
    }
    
    /* Edge-to-Edge Layout cu margini mici de siguranta */
    .dashboard-content { 
        padding: 10px 10px calc(var(--space-xxl) + 60px) 10px; 
    }
    
    .page-view { gap: 0; }
    
    .widget { 
        border-radius: 16px; 
        border: 1px solid var(--border);
        box-shadow: var(--shadow-sm);
        padding: var(--space-md);
        margin-bottom: var(--space-md);
    }
    
    .widget:hover { box-shadow: none; }
    
    .w-6, .w-8, .w-4 { grid-column: span 12; }
    
    /* Form Optimization */
    .form-grid { 
        grid-template-columns: 1fr; 
        align-items: stretch; 
        gap: var(--space-sm); 
        padding: 0; 
        border: none;
        background: transparent;
    }
    
    .form-group label { display: none; } /* Ascundem label-urile pe mobil */
    
    /* Fix for some inline styles that might break edge-to-edge */
    .form-row > div { border: none !important; padding: 0 !important; background: transparent !important; }
    
    /* Touch Targets */
    .btn-small, .btn-primary-form, .btn-wiz-next, .btn-wiz-prev, input, select {
        min-height: 48px;
    }
    
    /* Hover to Active feedback */
    /* Reseting transform on hover to prevent sticky hover */
    .btn-primary-form:hover, .btn-wiz-next:hover, .kpi-card:hover, .data-card:hover, .btn-info:hover {
        transform: none !important;
        box-shadow: none !important;
    }
    
    .btn-primary-form:active, .btn-wiz-next:active, .btn-small:active, .icon-btn:active, .profile-btn:active {
        transform: scale(0.97) !important;
        opacity: 0.9;
    }
    
    .kpi-card:active, .data-card:active {
        transform: scale(0.98) !important;
        background: var(--input-bg);
    }
    
    /* Modals & Others */
    .modal-card { padding: var(--space-lg); width: 95%;}
    #tutorialOverlay { align-items: flex-end; justify-content: center; padding: var(--space-md); padding-bottom: 90px; }
    
    #toast {
        bottom: 90px; /* Above bottom nav */
        width: 90%;
        padding: 12px 20px;
    }
}

/* Hide Bottom Nav on Desktop */
@media (min-width: 769px) {
    .bottom-nav { display: none !important; }
    #btnCloudNavHeader { display: none !important; } /* Asigurăm ascunderea butonului Cloud pe desktop */
}

/* Tablet Widget Stacking Optimization */
@media (max-width: 1100px) {
    .w-6, .w-8, .w-4 { grid-column: span 12; }
}

/* Clickwrap UI for Legal Terms */
.clickwrap-text { font-size: 0.75rem; color: var(--text-muted); opacity: 0.85; text-align: center; margin-top: var(--space-md); line-height: 1.5; }
.clickwrap-link { color: var(--accent); text-decoration: none; font-weight: 600; transition: all 0.2s ease; }
.clickwrap-link:hover { text-decoration: underline; color: var(--accent-hover); }
