/* ============================================
   TelegramADV Manager — Main Stylesheet
   Design: Dark Industrial / Terminal Aesthetic
   ============================================ */

:root {
    --bg-base: #0a0c10;
    --bg-surface: #111318;
    --bg-elevated: #181c24;
    --bg-card: #1e2330;
    --border: #2a3040;
    --border-bright: #3a4560;
    --accent: #2d9cff;
    --accent-dim: rgba(45, 156, 255, 0.15);
    --accent-glow: rgba(45, 156, 255, 0.4);
    --green: #22d98a;
    --green-dim: rgba(34, 217, 138, 0.15);
    --orange: #ff8c42;
    --orange-dim: rgba(255, 140, 66, 0.15);
    --red: #ff4d6a;
    --red-dim: rgba(255, 77, 106, 0.15);
    --yellow: #f5c542;
    --yellow-dim: rgba(245, 197, 66, 0.15);
    --purple: #9b6dff;
    --purple-dim: rgba(155, 109, 255, 0.15);
    --text-primary: #e8ecf0;
    --text-secondary: #8a9ab5;
    --text-muted: #4a5568;
    --sidebar-w: 260px;
    --topbar-h: 64px;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --font: 'Space Grotesk', sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

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

html { font-size: 15px; }

body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 40px; height: 40px;
    background: var(--accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    color: white;
    box-shadow: 0 0 20px var(--accent-glow);
    flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 1rem; letter-spacing: -0.02em; }
.brand-sub { font-size: 0.72rem; color: var(--text-secondary); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-group { margin-bottom: 8px; }

.nav-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 10px 10px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
    margin-bottom: 2px;
}

.nav-item i { width: 18px; text-align: center; font-size: 0.9rem; flex-shrink: 0; }
.nav-item span { flex: 1; }

.nav-item:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-dim);
    color: var(--accent);
    box-shadow: inset 3px 0 0 var(--accent);
}

.nav-badge {
    background: var(--red);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-meta { flex: 1; min-width: 0; }
.user-name { display: block; font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 0.72rem; color: var(--text-secondary); }

.logout-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.logout-btn:hover { background: var(--red-dim); color: var(--red); }

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

/* ========== TOPBAR ========== */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: none;
}

.topbar-title { font-weight: 600; font-size: 1.05rem; flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
    width: 38px; height: 38px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.95rem;
    position: relative;
    transition: all 0.2s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.notif-dot {
    position: absolute;
    top: -4px; right: -4px;
    background: var(--red);
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    width: 18px; height: 18px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg-surface);
}

.notif-wrapper { position: relative; }

.notif-dropdown {
    display: none;
    position: absolute;
    right: 0; top: calc(100% + 8px);
    width: 320px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    z-index: 200;
    overflow: hidden;
}
.notif-dropdown.open { display: block; }

.notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.85rem;
}
.notif-clear { font-size: 0.75rem; color: var(--accent); text-decoration: none; }
.notif-clear:hover { text-decoration: underline; }

.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}
.notif-item:hover { background: var(--bg-elevated); }
.notif-title { font-weight: 600; font-size: 0.82rem; margin-bottom: 2px; }
.notif-msg { font-size: 0.78rem; color: var(--text-secondary); }
.notif-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.notif-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.notif-empty i { margin-right: 6px; color: var(--green); }

/* ========== PAGE CONTENT ========== */
.page-content { flex: 1; padding: 28px; }

/* ========== ALERTS ========== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: var(--green-dim); border: 1px solid rgba(34,217,138,0.3); color: var(--green); }
.alert-danger  { background: var(--red-dim);   border: 1px solid rgba(255,77,106,0.3);  color: var(--red);   }
.alert-warning { background: var(--yellow-dim); border: 1px solid rgba(245,197,66,0.3); color: var(--yellow); }
.alert-info    { background: var(--accent-dim); border: 1px solid rgba(45,156,255,0.3); color: var(--accent); }

/* ========== CARDS ========== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title i { color: var(--accent); }

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s;
}
.stat-card:hover { border-color: var(--border-bright); transform: translateY(-1px); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-icon.blue   { background: var(--accent-dim);  color: var(--accent); }
.stat-icon.green  { background: var(--green-dim);  color: var(--green); }
.stat-icon.orange { background: var(--orange-dim); color: var(--orange); }
.stat-icon.red    { background: var(--red-dim);    color: var(--red); }
.stat-icon.purple { background: var(--purple-dim); color: var(--purple); }

.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.stat-label { font-size: 0.78rem; color: var(--text-secondary); margin-top: 4px; }

/* ========== TABLES ========== */
.table-wrap { overflow-x: auto; }

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

.data-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(42,48,64,0.5);
    vertical-align: middle;
}

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

.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }

/* ========== BADGES ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.74rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success   { background: var(--green-dim);  color: var(--green); }
.badge-danger    { background: var(--red-dim);    color: var(--red); }
.badge-warning   { background: var(--yellow-dim); color: var(--yellow); }
.badge-info      { background: var(--accent-dim); color: var(--accent); }
.badge-secondary { background: rgba(138,154,181,0.15); color: var(--text-secondary); }
.badge-orange    { background: var(--orange-dim); color: var(--orange); }
.badge-primary   { background: var(--purple-dim); color: var(--purple); }
.badge-dark      { background: rgba(30,35,48,0.8); color: var(--text-muted); border: 1px solid var(--border); }

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 0.86rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary  { background: var(--accent);  color: white; }
.btn-primary:hover  { background: #1a8bef; box-shadow: 0 0 20px var(--accent-glow); }
.btn-success  { background: var(--green);   color: #0a1a10; }
.btn-success:hover  { background: #1bc478; }
.btn-danger   { background: var(--red);     color: white; }
.btn-danger:hover   { background: #e03055; }
.btn-warning  { background: var(--yellow);  color: #1a1000; }
.btn-warning:hover  { background: #e0b030; }
.btn-secondary { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border-bright); color: var(--text-primary); }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; border-radius: 6px; }
.btn-icon { padding: 7px 10px; }

.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ========== FORMS ========== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.03em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
select,
textarea {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.88rem;
    padding: 10px 14px;
    width: 100%;
    transition: border-color 0.2s;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

textarea { resize: vertical; min-height: 120px; }

.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.form-actions {
    display: flex;
    gap: 10px;
    padding-top: 8px;
}

/* Checkbox grid for days/hours */
.check-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.check-item {
    position: relative;
}

.check-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0; height: 0;
}

.check-item label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px; height: 38px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.15s;
    user-select: none;
}

.check-item input:checked + label {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.hour-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 6px;
}

.hour-grid .check-item label {
    width: 100%;
    font-family: var(--mono);
    font-size: 0.75rem;
}

/* ========== PAGE HEADER ========== */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header-left h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-header-left p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-top: 4px;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
    opacity: 0.3;
}

.empty-state p { font-size: 0.9rem; margin-bottom: 20px; }

/* ========== TABS ========== */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tab-btn {
    padding: 10px 16px;
    font-family: var(--font);
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ========== MODAL ========== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.modal-close {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-elevated);
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
}
.modal-close:hover { background: var(--red-dim); color: var(--red); }

.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ========== LOGIN PAGE ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(45,156,255,0.06) 0%, transparent 70%);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
    position: relative;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .brand-icon {
    margin: 0 auto 12px;
    width: 52px; height: 52px;
    font-size: 26px;
}

.login-logo h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-logo p { color: var(--text-secondary); font-size: 0.85rem; margin-top: 4px; }

/* ========== SCHEDULE CALENDAR ========== */
.schedule-grid {
    display: grid;
    grid-template-columns: 80px repeat(24, 1fr);
    gap: 2px;
    font-size: 0.7rem;
}

.schedule-cell {
    background: var(--bg-elevated);
    border-radius: 4px;
    padding: 4px;
    min-height: 36px;
}

.schedule-cell.has-slot {
    background: var(--accent-dim);
    border: 1px solid var(--accent);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: flex; }
    .hour-grid { grid-template-columns: repeat(8, 1fr); }
}

@media (max-width: 600px) {
    .page-content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .hour-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ========== UTILITIES ========== */
.text-muted  { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-orange { color: var(--orange); }
.fw-600 { font-weight: 600; }
.mono { font-family: var(--mono); }
.flex { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }

/* Divider */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Progress bar */
.progress-bar {
    background: var(--bg-elevated);
    border-radius: 20px;
    height: 6px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 20px;
    background: linear-gradient(90deg, var(--accent), var(--purple));
    transition: width 0.4s ease;
}
