/* Premium Dashboard & Theme Variable Declarations */
:root {
    --bg-primary: #f4f6f9;
    --bg-sidebar: #1e293b;
    --bg-sidebar-hover: #334155;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --accent-color: #4f46e5;
    --accent-color-hover: #4338ca;
    
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.04), 0 10px 10px -5px rgba(0, 0, 0, 0.02);

    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 24px;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-sidebar: #020617;
    --bg-sidebar-hover: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --accent-color: #6366f1;
    --accent-color-hover: #4f46e5;
    
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
    --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

/* Global Reset & Basic Layout */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.sidebar .brand {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar .brand img {
    height: 35px;
}

.sidebar .brand span {
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.5px;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 12px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.sidebar-menu li a:hover {
    color: #ffffff;
    background-color: var(--bg-sidebar-hover);
}

.sidebar-menu li.active a {
    color: #ffffff;
    background-color: var(--accent-color);
    box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.35);
}

.sidebar-menu li a i {
    font-size: 1.1rem;
}

/* Main Content Area */
.main-content {
    margin-left: 260px;
    padding: 24px;
    min-height: 100vh;
    transition: all 0.3s ease;
}

/* Header & Navbar */
.main-header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 12px;
    z-index: 99;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.toggle-sidebar {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.toggle-sidebar:hover {
    background-color: var(--border-color);
}

/* Sidebar Backdrop for Mobile */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Mobile Close Sidebar Button */
.btn-close-sidebar {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.btn-close-sidebar:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Desktop Collapsible Sidebar System */
@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar {
        width: 70px;
    }
    body.sidebar-collapsed .sidebar .brand {
        padding: 24px 10px;
        justify-content: center;
    }
    body.sidebar-collapsed .sidebar .brand span.brand-text {
        display: none;
    }
    body.sidebar-collapsed .sidebar-menu {
        padding: 20px 8px;
    }
    body.sidebar-collapsed .sidebar-menu li a {
        padding: 12px 0;
        justify-content: center;
        gap: 0;
    }
    body.sidebar-collapsed .sidebar-menu li a span {
        display: none;
    }
    body.sidebar-collapsed .sidebar-footer {
        padding: 15px 10px !important;
    }
    body.sidebar-collapsed .sidebar-footer span {
        display: none;
    }
    body.sidebar-collapsed .main-content {
        margin-left: 70px;
    }
}

/* User Profile & Dark Mode Button */
.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-toggle-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.theme-toggle-btn:hover {
    background-color: var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.user-profile img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-color);
}

.user-profile .user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

/* Stats Cards */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.stat-card.card-total::before { background-color: #3b82f6; }
.stat-card.card-today::before { background-color: #10b981; }
.stat-card.card-scheduled::before { background-color: #f59e0b; }
.stat-card.card-draft::before { background-color: #64748b; }
.stat-card.card-emergency::before { background-color: #ef4444; }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 16px;
}

.card-total .stat-icon { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.card-today .stat-icon { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.card-scheduled .stat-icon { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.card-draft .stat-icon { background: rgba(100, 116, 139, 0.1); color: #64748b; }
.card-emergency .stat-icon { background: rgba(239, 68, 68, 0.1); color: #ef4444; }

.stat-val {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-lbl {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Premium Card Element */
.custom-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    margin-bottom: 24px;
}

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

.custom-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.custom-card-body {
    padding: 24px;
}

/* Buttons */
.btn-primary {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    font-weight: 600;
    padding: 10px 24px;
    border-radius: var(--border-radius-sm);
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
    transition: all 0.2s;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--accent-color-hover);
    border-color: var(--accent-color-hover);
    box-shadow: 0 6px 14px rgba(79, 70, 229, 0.3);
}

.btn-light {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
    padding: 10px 24px;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s;
}

.btn-light:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s;
}

/* Badges styling */
.badge-category {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.priority-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    display: inline-block;
}

.priority-emergency { background-color: rgba(239, 68, 68, 0.12); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.2); }
.priority-high { background-color: rgba(245, 158, 11, 0.12); color: #d97706; border: 1px solid rgba(245, 158, 11, 0.2); }
.priority-normal { background-color: rgba(59, 130, 246, 0.12); color: #2563eb; border: 1px solid rgba(59, 130, 246, 0.2); }
.priority-low { background-color: rgba(100, 116, 139, 0.12); color: #475569; border: 1px solid rgba(100, 116, 139, 0.2); }

.status-published { background-color: rgba(16, 185, 129, 0.12); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.2); font-size: 0.75rem; padding: 4px 10px; border-radius: 20px; font-weight: 600; }
.status-draft { background-color: rgba(100, 116, 139, 0.12); color: #64748b; border: 1px solid rgba(100, 116, 139, 0.2); font-size: 0.75rem; padding: 4px 10px; border-radius: 20px; font-weight: 600; }
.status-inactive { background-color: rgba(239, 68, 68, 0.12); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.2); font-size: 0.75rem; padding: 4px 10px; border-radius: 20px; font-weight: 600; }

/* Phone Live Preview Wrapper */
.phone-preview-wrapper {
    position: sticky;
    top: 100px;
    display: flex;
    justify-content: center;
}

/* Smartphone Container Mockup */
.smartphone-container {
    width: 320px;
    max-width: 100%;
    height: 640px;
    background-color: #000;
    border-radius: 40px;
    padding: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 4px solid #2e2e2e;
    position: relative;
    overflow: hidden;
}

/* Phone notch */
.smartphone-notch {
    width: 150px;
    height: 25px;
    background: #000;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
}

.smartphone-notch::before {
    content: '';
    width: 50px;
    height: 4px;
    background: #1e1e1e;
    border-radius: 2px;
    margin-bottom: 5px;
}

/* Screen */
.smartphone-screen {
    width: 100%;
    height: 100%;
    border-radius: 30px;
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 0 100px rgba(0,0,0,0.5);
    transition: background 0.3s;
}

/* Status Bar */
.smartphone-statusbar {
    height: 35px;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 9;
    background: linear-gradient(to bottom, rgba(0,0,0,0.4), rgba(0,0,0,0));
}

.statusbar-right {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Screen Content modes: Lockscreen and In-App */
.smartphone-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 15px;
    position: relative;
    z-index: 8;
    overflow-y: auto;
}

/* Lockscreen Notification Cards */
.lockscreen-noti-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 16px;
    padding: 14px;
    margin-top: 15px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    color: #000;
}

.lockscreen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #555;
}

.lockscreen-title {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.2;
}

.lockscreen-msg {
    font-size: 0.78rem;
    color: #333;
    line-height: 1.3;
    word-break: break-word;
}

/* In-App Notification Screen */
.inapp-preview-screen {
    background-color: #f3f4f6;
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 7;
    display: flex;
    flex-direction: column;
    padding-top: 35px; /* for statusbar */
}

.inapp-appheader {
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.inapp-appheader i {
    color: #4f46e5;
    font-size: 1.2rem;
}

.inapp-appheader span {
    font-weight: 700;
    font-size: 0.9rem;
    color: #111827;
}

.inapp-list {
    padding: 12px;
    flex-grow: 1;
    overflow-y: auto;
}

.inapp-noti-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 10px;
    border-left: 4px solid #4f46e5;
    position: relative;
    animation: popIn 0.3s ease;
}

.inapp-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.inapp-time {
    font-size: 0.65rem;
    color: #9ca3af;
}

.inapp-title {
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: #111827;
}

.inapp-msg {
    font-size: 0.75rem;
    color: #4b5563;
    line-height: 1.3;
    word-break: break-word;
}

.inapp-unread-dot {
    width: 6px;
    height: 6px;
    background-color: #ef4444;
    border-radius: 50%;
    position: absolute;
    top: 14px;
    right: 14px;
}

/* Animations */
@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes popIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Form Styles & Validation */
.form-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.form-control, .form-select {
    border-color: var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.char-counter {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
    margin-top: 4px;
}

/* Select2 Custom Theme Alignment */
.select2-container--bootstrap-5 .select2-selection {
    border-color: var(--border-color) !important;
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-radius: var(--border-radius-sm) !important;
    padding: 6px 12px !important;
    min-height: 42px !important;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    color: var(--text-primary) !important;
    line-height: 28px !important;
}

.select2-container--bootstrap-5 .select2-dropdown {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

.select2-container--bootstrap-5 .select2-search__field {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: var(--accent-color) !important;
}

.select2-container--bootstrap-5 .select2-results__option {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .select2-container--bootstrap-5 .select2-results__option {
    background-color: var(--bg-card);
}

[data-theme="dark"] .select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: var(--accent-color) !important;
}

/* Breadcrumb Styling */
.breadcrumb-item a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}
.breadcrumb-item.active {
    color: var(--text-secondary);
}

/* Datatable customizations */
.dataTables_wrapper {
    padding: 10px 0;
}
div.dataTables_wrapper div.dataTables_filter {
    text-align: right;
    margin-bottom: 15px;
}
div.dataTables_wrapper div.dataTables_length {
    margin-bottom: 15px;
}
table.dataTable {
    border-collapse: collapse !important;
    width: 100% !important;
    border-color: var(--border-color) !important;
}
table.dataTable thead th {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    font-weight: 600 !important;
    border-bottom: 2px solid var(--border-color) !important;
    padding: 12px 16px !important;
}
table.dataTable tbody td {
    padding: 12px 16px !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    vertical-align: middle !important;
    background-color: var(--bg-card) !important;
}
.page-link {
    color: var(--accent-color);
    background-color: var(--bg-card);
    border-color: var(--border-color);
}
.page-link:hover {
    color: var(--accent-color-hover);
    background-color: var(--border-color);
    border-color: var(--border-color);
}
.page-item.active .page-link {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}
.dt-buttons {
    margin-bottom: 15px;
}

/* Custom 5-column grid layout for desktop */
@media (min-width: 992px) {
    .col-lg-2-4 {
        flex: 0 0 auto;
        width: 20%;
    }
}

/* Floating Action Button (FAB) for live preview */
.btn-preview-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    z-index: 1045;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn-preview-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.6);
}
.btn-preview-fab:active {
    transform: scale(0.95);
}
body.modal-open .btn-preview-fab {
    display: none !important;
}

/* Mobile Responsiveness */
@media (max-width: 991.98px) {
    .sidebar {
        left: -260px;
    }
    .sidebar.show {
        left: 0;
        z-index: 101; /* Ensure sidebar is above backdrop */
    }
    .main-content {
        margin-left: 0;
        padding: 16px;
    }
    .toggle-sidebar {
        display: flex; /* Keep toggle button visible */
    }
    .phone-preview-wrapper {
        position: relative;
        top: 0;
        margin-top: 0;
        padding: 10px 0;
    }
    .smartphone-container {
        box-shadow: none;
        margin-bottom: 0;
    }
    
    #mobilePreviewModalBody .phone-preview-wrapper {
        position: static;
        top: auto;
        margin: 0;
        padding: 0;
        width: 100%;
    }
    
    #mobilePreviewModalBody .phone-preview-wrapper h6 {
        display: none; /* Hide preview header text inside modal body to save vertical space */
    }
}

@media (max-width: 767.98px) {
    .stat-card {
        padding: 16px;
    }
    .stat-val {
        font-size: 1.4rem;
    }
    .stat-lbl {
        font-size: 0.8rem;
    }
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
        margin-bottom: 12px;
    }
    .custom-card-header {
        padding: 16px;
    }
    .custom-card-body {
        padding: 16px;
    }
}

@media (max-width: 575.98px) {
    .main-header {
        padding: 12px 16px;
        margin-bottom: 16px;
    }
    .header-actions {
        gap: 12px;
    }
    .user-profile img {
        width: 32px;
        height: 32px;
    }
    .theme-toggle-btn {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }
    div.dataTables_wrapper div.dataTables_info,
    div.dataTables_wrapper div.dataTables_paginate {
        text-align: center !important;
        display: flex;
        justify-content: center;
        margin-top: 8px;
    }
    .pagination {
        font-size: 0.85rem;
    }
    
    /* Flex grid adjustments inside lists headers */
    .custom-card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }
    .custom-card-header > div {
        width: 100%;
        justify-content: flex-start !important;
    }
}
