/* ============================================================
   TELEGRAM DASHBOARD — CUSTOM CSS
   ============================================================ */

/* ---- CSS Variables (Light Mode) ---- */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --navbar-height: 60px;

    --sidebar-bg: #1a1d23;
    --sidebar-text: #b0b8c9;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(99, 102, 241, 0.15);
    --sidebar-active-text: #818cf8;
    --sidebar-active-border: #6366f1;
    --sidebar-border: rgba(255,255,255,0.06);
    --sidebar-section-label: #4b5563;

    --topbar-bg: rgba(255, 255, 255, 0.95);
    --topbar-border: rgba(0,0,0,0.06);
    --topbar-shadow: 0 1px 12px rgba(0,0,0,0.08);

    --card-bg: #ffffff;
    --card-border: rgba(0,0,0,0.07);
    --body-bg: #f0f2f7;
    --text-primary: #1a1d23;
    --text-muted: #6b7280;

    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Dark Mode Variables ---- */
[data-bs-theme="dark"] {
    --topbar-bg: rgba(30, 33, 42, 0.97);
    --topbar-border: rgba(255,255,255,0.06);
    --topbar-shadow: 0 1px 12px rgba(0,0,0,0.3);
    --card-bg: #1e212a;
    --card-border: rgba(255,255,255,0.06);
    --body-bg: #14161e;
    --text-primary: #e2e8f0;
    --text-muted: #94a3b8;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}

.sidebar-header {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-logo {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.sidebar-brand {
    font-size: 0.9rem;
    font-weight: 700;
    color: #f1f5f9;
    line-height: 1.2;
}

.sidebar-sub {
    font-size: 0.7rem;
    color: var(--sidebar-section-label);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-section-label);
    padding: 0.75rem 1.25rem 0.3rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: var(--transition);
    margin: 1px 0;
    position: relative;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.05);
    color: var(--sidebar-text-hover);
    border-left-color: rgba(255,255,255,0.2);
}

.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    border-left-color: var(--sidebar-active-border);
}

.sidebar-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #6366f1, #a78bfa);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #f1f5f9;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-role-admin { color: #f87171; }
.badge-role-manager { color: #fbbf24; }
.badge-role-viewer { color: #94a3b8; }

/* Mobile sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
    backdrop-filter: blur(2px);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Top Navbar ---- */
.top-navbar {
    height: var(--navbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    box-shadow: var(--topbar-shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.sidebar-toggle {
    display: none;
    transition: var(--transition);
}

.sidebar-toggle:hover { opacity: 0.7; }

/* ---- Page Content ---- */
.page-content {
    flex: 1;
    padding: 1.5rem;
}

/* ---- Nav Avatar ---- */
.nav-avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #6366f1, #a78bfa);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.75rem;
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
    border-radius: 12px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12) !important;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 0.25rem;
}

.stat-sub {
    font-size: 0.75rem;
}

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

.stat-icon-blue { background: rgba(99,102,241,0.1); color: #6366f1; }
.stat-icon-purple { background: rgba(168,85,247,0.1); color: #a855f7; }
.stat-icon-green { background: rgba(16,185,129,0.1); color: #10b981; }
.stat-icon-orange { background: rgba(245,158,11,0.1); color: #f59e0b; }

/* ============================================================
   STATUS BADGES
   ============================================================ */
.status-badge-draft { background: #6b728020; color: #6b7280; border: 1px solid #6b728040; padding: .25em .6em; border-radius: 6px; font-size: .75rem; font-weight: 600; }
.status-badge-scheduled { background: #f59e0b20; color: #d97706; border: 1px solid #f59e0b40; padding: .25em .6em; border-radius: 6px; font-size: .75rem; font-weight: 600; }
.status-badge-running { background: #3b82f620; color: #2563eb; border: 1px solid #3b82f640; padding: .25em .6em; border-radius: 6px; font-size: .75rem; font-weight: 600; }
.status-badge-completed { background: #10b98120; color: #059669; border: 1px solid #10b98140; padding: .25em .6em; border-radius: 6px; font-size: .75rem; font-weight: 600; }
.status-badge-failed { background: #ef444420; color: #dc2626; border: 1px solid #ef444440; padding: .25em .6em; border-radius: 6px; font-size: .75rem; font-weight: 600; }
.status-badge-paused { background: #8b5cf620; color: #7c3aed; border: 1px solid #8b5cf640; padding: .25em .6em; border-radius: 6px; font-size: .75rem; font-weight: 600; }

/* ============================================================
   CONTACT AVATARS
   ============================================================ */
.contact-avatar {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #6366f1, #a78bfa);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.contact-avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
}

/* ============================================================
   USER AVATARS
   ============================================================ */
.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-avatar-admin { background: linear-gradient(135deg, #ef4444, #f87171); }
.user-avatar-manager { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.user-avatar-viewer { background: linear-gradient(135deg, #6b7280, #9ca3af); }

/* ============================================================
   CHART
   ============================================================ */
.chart-container {
    position: relative;
}

.chart-center-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

/* ============================================================
   DRAG & DROP UPLOAD ZONE
   ============================================================ */
.drop-zone {
    border: 2px dashed rgba(99,102,241,0.35);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(99,102,241,0.02);
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: #6366f1;
    background: rgba(99,102,241,0.06);
    box-shadow: 0 0 0 4px rgba(99,102,241,0.1);
}

.drop-zone.drag-over {
    transform: scale(1.01);
}

.drop-zone-icon {
    font-size: 3rem;
    color: #6366f1;
    opacity: 0.7;
    display: block;
    margin-bottom: 1rem;
}

.drop-zone-text {
    font-size: 1rem;
    color: var(--text-primary);
}

.drop-zone-inner { width: 100%; }

/* CSV column list */
.column-list { display: flex; flex-direction: column; gap: 0.75rem; }
.column-item { padding: 0.6rem 0.75rem; border-radius: 8px; background: rgba(0,0,0,0.02); border: 1px solid rgba(0,0,0,0.06); }
[data-bs-theme="dark"] .column-item { background: rgba(255,255,255,0.03); border-color: rgba(255,255,255,0.06); }

/* ============================================================
   CAMPAIGN CREATE — MESSAGE PREVIEW
   ============================================================ */
.telegram-preview-wrapper {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--card-border);
}

.telegram-preview-header {
    background: #2b5278;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.telegram-preview-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
}

.telegram-preview-body {
    background: #1c1c1e;
    min-height: 160px;
    padding: 1rem;
    background-image: radial-gradient(rgba(255,255,255,0.03) 1px, transparent 0);
    background-size: 20px 20px;
}

.telegram-message {
    background: #2b5278;
    border-radius: 12px 12px 12px 0;
    padding: 0.75rem 0.875rem;
    max-width: 85%;
    display: inline-block;
    position: relative;
}

.telegram-message-text {
    color: #ffffff;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
}

.telegram-message-text p { margin: 0 0 0.25rem; }
.telegram-message-text p:last-child { margin: 0; }
.telegram-message-text strong { font-weight: 600; }
.telegram-message-text code { background: rgba(255,255,255,0.12); padding: 1px 5px; border-radius: 4px; font-size: 0.85em; }
.telegram-message-text a { color: #5bc8f5; }

.telegram-message-time {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.5);
    text-align: right;
    margin-top: 4px;
}

/* Schedule Options */
.schedule-option { position: relative; }
.schedule-option-label {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    border: 2px solid var(--card-border);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}
.schedule-option-label:hover { border-color: #6366f1; background: rgba(99,102,241,0.03); }
.schedule-option .btn-check:checked + .schedule-option-label {
    border-color: #6366f1;
    background: rgba(99,102,241,0.06);
}
.schedule-option-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
[data-bs-theme="dark"] .schedule-option-icon { background: rgba(255,255,255,0.06); }

/* Campaign Summary Items */
.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--card-border);
}
.summary-item:last-of-type { border-bottom: none; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    background: var(--body-bg);
}

.login-bg {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.login-shapes {
    position: absolute;
    inset: 0;
}

.login-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float 8s ease-in-out infinite;
}

.login-shape-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #6366f1, transparent);
    top: -150px;
    left: -200px;
    animation-delay: 0s;
}

.login-shape-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #818cf8, transparent);
    top: 40%;
    right: -100px;
    animation-delay: 3s;
}

.login-shape-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, #3b82f6, transparent);
    bottom: -100px;
    left: 30%;
    animation-delay: 6s;
}

@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-30px) scale(1.05); }
}

.login-card-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    padding: 1rem;
}

.login-card {
    border-radius: 20px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
}

.login-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    box-shadow: 0 8px 32px rgba(99,102,241,0.35);
}

/* ============================================================
   STATUS DOT
   ============================================================ */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot-success { background: #10b981; }
.status-dot-warning { background: #f59e0b; }
.status-dot-danger { background: #ef4444; }
.status-dot.pulse { animation: pulse-dot 1.5s ease-in-out infinite; }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.85); }
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    border-radius: 12px;
    transition: var(--transition);
}

/* ============================================================
   TABLES
   ============================================================ */
.table-danger-subtle { background: rgba(239,68,68,0.04); }
.table > :not(caption) > * > * {
    vertical-align: middle;
}

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb {
    font-size: 0.8rem;
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

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

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .page-content {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 575.98px) {
    .top-navbar {
        padding: 0 0.875rem;
    }

    .page-content {
        padding: 0.75rem;
    }
}

/* ============================================================
   DARK MODE OVERRIDES
   ============================================================ */
[data-bs-theme="dark"] .card {
    background-color: #1e212a;
    border-color: rgba(255,255,255,0.07);
}

[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(255,255,255,0.02);
    --bs-table-hover-bg: rgba(255,255,255,0.04);
}

[data-bs-theme="dark"] .table-light {
    --bs-table-bg: rgba(255,255,255,0.04);
    color: inherit;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .input-group-text {
    background-color: #252830;
    border-color: rgba(255,255,255,0.1);
    color: #e2e8f0;
}

[data-bs-theme="dark"] .modal-content {
    background-color: #1e212a;
    border-color: rgba(255,255,255,0.1);
}

[data-bs-theme="dark"] .dropdown-menu {
    background-color: #252830;
    border-color: rgba(255,255,255,0.1);
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: rgba(255,255,255,0.06);
}

[data-bs-theme="dark"] .login-card {
    background: #1e212a;
}

[data-bs-theme="dark"] .drop-zone {
    background: rgba(99,102,241,0.04);
    border-color: rgba(99,102,241,0.25);
}

[data-bs-theme="dark"] .telegram-preview-body {
    background: #0e0e10;
}

/* ============================================================
   UTILITY
   ============================================================ */
.font-monospace { font-family: 'Fira Code', 'Consolas', monospace !important; }
.btn-xs { padding: 0.2rem 0.45rem; font-size: 0.75rem; }

/* Smooth page transitions */
.page-content > * {
    animation: fadeInUp 0.25s ease-out;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Nav pills active */
.nav-pills .nav-link.active { font-weight: 600; }

/* Alert improvements */
.alert { border-radius: 10px; }

/* Print: hide sidebar */
@media print {
    .sidebar, .top-navbar { display: none !important; }
    .main-content { margin-left: 0 !important; }
}
