/* ============================================
   Infotechzen Website Template Generator
   Custom Stylesheet
   ============================================ */

/* ---------- Base ---------- */
:root {
    --sidebar-width: 260px;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #4361ee;
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --primary-light: rgba(67, 97, 238, 0.1);
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --info: #06b6d4;
    --body-bg: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.08);
    --transition: all 0.2s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--body-bg);
    color: #1e293b;
    overflow-x: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo {
    height: 36px;
    width: auto;
    filter: brightness(0) invert(1);
}

.sidebar-logo-text {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
}

.sidebar-logo-text i {
    font-size: 1.4rem;
    color: var(--primary);
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
}

.sidebar-nav .nav-link.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.4);
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

/* ---------- Sidebar Footer & Logout (FIXED) ---------- */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    margin-bottom: 8px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #7209b7);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    color: #e2e8f0;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    color: var(--sidebar-text);
    font-size: 0.75rem;
}

.logout-link {
    display: flex !important;
    align-items: center;
    gap: 12px;
    padding: 11px 16px !important;
    color: #f87171 !important;
    text-decoration: none !important;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    margin: 0 -16px;
}

.logout-link:hover {
    background: rgba(248, 113, 113, 0.1) !important;
    color: #fca5a5 !important;
}

.logout-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

/* ---------- Main Content ---------- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* ---------- Top Bar ---------- */
.topbar {
    background: #fff;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #64748b;
    cursor: pointer;
    display: none;
    padding: 4px;
}

.topbar-title {
    font-weight: 700;
    font-size: 1.05rem;
    margin: 0;
    color: #0f172a;
}

.topbar-time {
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 500;
}

/* ---------- Content Area ---------- */
.content-area {
    padding: 24px;
}

/* ---------- Stat Cards ---------- */
.stat-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    border: 1px solid rgba(0,0,0,0.03);
}

.stat-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

/* Individual stat card accent colors */
.stat-card[style*="4361ee"] .stat-icon {
    background: rgba(67, 97, 238, 0.12);
    color: #4361ee;
}
.stat-card[style*="2ec4b6"] .stat-icon {
    background: rgba(46, 196, 182, 0.12);
    color: #2ec4b6;
}
.stat-card[style*="ff6b6b"] .stat-icon {
    background: rgba(255, 107, 107, 0.12);
    color: #ff6b6b;
}
.stat-card[style*="f77f00"] .stat-icon {
    background: rgba(247, 127, 0, 0.12);
    color: #f77f00;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.2;
    color: #0f172a;
}

.stat-label {
    font-size: 0.82rem;
    color: #94a3b8;
    font-weight: 500;
}

/* ---------- Cards ---------- */
.card {
    border-radius: 16px !important;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
}

.card-header {
    border-radius: 16px 16px 0 0 !important;
    padding: 16px 20px;
}

/* ---------- Buttons ---------- */
.btn-primary-gradient {
    background: linear-gradient(135deg, var(--primary), #3a0ca3);
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: 10px;
    padding: 10px 24px;
    transition: var(--transition);
}

.btn-primary-gradient:hover {
    background: linear-gradient(135deg, var(--primary-dark), #2d0892);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(67, 97, 238, 0.35);
}

.btn-primary-gradient:active {
    transform: translateY(0);
}

.btn-primary-gradient:disabled {
    opacity: 0.65;
    transform: none;
    box-shadow: none;
}

/* ---------- Form Controls ---------- */
.form-control, .form-select {
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-group-text {
    border-radius: 10px 0 0 10px;
    border: 1.5px solid #e2e8f0;
    background: #f8fafc;
    color: #64748b;
}

.input-group .form-control {
    border-radius: 0 10px 10px 0;
}

/* ---------- Table ---------- */
.table {
    font-size: 0.88rem;
}

.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    border-bottom-width: 1px;
}

.table td {
    vertical-align: middle;
}

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    padding: 6px 14px;
    font-size: 0.88rem;
}

.dataTables_wrapper .dataTables_length select {
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    padding: 4px 8px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 8px !important;
    margin: 0 2px;
}

/* ---------- Activity List ---------- */
.activity-list {
    max-height: 380px;
    overflow-y: auto;
    padding: 0 20px;
}

.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
    margin-top: 6px;
}

.activity-content {
    flex: 1;
    min-width: 0;
}

/* ---------- Generate Page: Category Filters ---------- */
#categoryFilters {
    gap: 6px !important;
}

#categoryFilters .cat-filter {
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 5px 12px;
    white-space: nowrap;
}

#categoryFilters .cat-filter.active {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}

/* ---------- Generate Page: Template Select Grid ---------- */
#templateGrid {
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
}

.template-card-wrap {
    margin-bottom: 4px;
}

.template-select-card {
    position: relative;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    background: #fff;
}

.template-select-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.15);
    transform: translateY(-1px);
}

.template-select-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light), 0 4px 15px rgba(67, 97, 238, 0.2);
}

.template-select-card.selected::after {
    content: '\f058';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 6px;
    right: 6px;
    color: var(--primary);
    font-size: 1.1rem;
    background: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.template-thumb {
    width: 100%;
    height: 80px;
    object-fit: cover;
    display: block;
}

.template-thumb-placeholder {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    color: #cbd5e1;
}

.template-select-name {
    padding: 6px 10px 1px;
    font-weight: 600;
    font-size: 0.78rem;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-select-cat {
    padding: 0 10px 6px;
    font-size: 0.68rem;
    color: #94a3b8;
}

/* ---------- Generate Page: Slug Preview ---------- */
.slug-preview-box {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    padding: 12px 16px;
}

.slug-preview-box code {
    color: var(--primary);
    font-weight: 600;
    word-break: break-all;
    font-size: 0.88rem;
}

/* ---------- Templates Page: Category Filters ---------- */
#tplCatFilters {
    gap: 6px !important;
}

#tplCatFilters .tpl-cat-btn {
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 5px 12px;
    white-space: nowrap;
}

#tplCatFilters .tpl-cat-btn.active {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}

/* ---------- Templates Page: Card Grid ---------- */
.tpl-card-wrap {
    margin-bottom: 8px;
}

.tpl-card {
    border: 1px solid #e2e8f0 !important;
    overflow: hidden;
    height: 100%;
}

.tpl-card .card-img-top-wrapper {
    height: 150px;
    overflow: hidden;
    background: #f8fafc;
}

.tpl-card .card-img-top {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.tpl-card:hover .card-img-top {
    transform: scale(1.05);
}

.card-img-top-placeholder {
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
}

.tpl-card .card-body {
    padding: 14px;
}

.tpl-card .card-body h6 {
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.tpl-card .btn-group {
    gap: 4px;
}

.tpl-card .btn-group .btn {
    padding: 4px 8px;
    font-size: 0.78rem;
    border-radius: 8px !important;
}

/* ---------- Settings Page ---------- */
.settings-section {
    margin-bottom: 24px;
}

.settings-section h6 {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* ---------- Login Page ---------- */
.login-page {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 440px;
}

.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 40px 36px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), #7209b7);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: #fff;
    font-size: 1.6rem;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 4px;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.8rem;
}

/* OTP Input */
.otp-input {
    font-size: 2rem !important;
    letter-spacing: 12px;
    font-weight: 700;
    color: #0f172a;
}

/* ---------- Badge ---------- */
.badge {
    font-weight: 500;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 0.75rem;
}

/* ---------- CodeMirror Override ---------- */
.CodeMirror {
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    font-size: 0.88rem;
}

/* ---------- Sidebar Overlay (Mobile) ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
}

.sidebar-overlay.show {
    display: block;
}

/* ---------- Modal Overrides ---------- */
.modal-content {
    border-radius: 16px !important;
    border: none !important;
}

.modal-header {
    border-bottom: 1px solid #f1f5f9 !important;
    padding: 16px 20px;
}

.modal-footer {
    border-top: 1px solid #f1f5f9 !important;
    padding: 12px 20px;
}

.modal-body {
    padding: 20px;
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .content-area {
        padding: 16px;
    }

    .topbar {
        padding: 12px 16px;
    }

    .logout-link {
        margin: 0;
    }
}

@media (max-width: 575.98px) {
    .login-card {
        padding: 28px 20px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .template-thumb, .template-thumb-placeholder {
        height: 60px;
    }

    .tpl-card .card-img-top-wrapper,
    .card-img-top-placeholder {
        height: 120px;
    }

    #templateGrid {
        max-height: 280px;
    }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    animation: fadeIn 0.3s ease;
}

.stat-card {
    animation: fadeIn 0.3s ease;
}

.stat-card:nth-child(2) { animation-delay: 0.05s; }
.stat-card:nth-child(3) { animation-delay: 0.1s; }
.stat-card:nth-child(4) { animation-delay: 0.15s; }

/* ---------- Utilities ---------- */
.btn-xs {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 6px;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- SweetAlert2 Overrides ---------- */
.swal2-popup {
    border-radius: 16px !important;
    font-family: var(--font) !important;
}

.swal2-title {
    font-size: 1.15rem !important;
    font-weight: 700 !important;
}

.swal2-html-container {
    font-size: 0.92rem !important;
}

.swal2-confirm {
    border-radius: 10px !important;
    font-weight: 600 !important;
    padding: 10px 24px !important;
}

.swal2-cancel {
    border-radius: 10px !important;
    font-weight: 500 !important;
    padding: 10px 24px !important;
}