/* =========================================
   Control Panel & Modern Settings Redesign
   ========================================= */

/* Root & Variables */
:root {
    --cp-bg: #ffffff;
    --cp-sidebar-bg: #f8f9fa;
    --cp-text: #333333;
    --cp-text-muted: #6c757d;
    --cp-border: #e9ecef;
    --cp-primary: #0d6efd;
    --cp-primary-hover: #0b5ed7;
    --cp-radius: 12px;
    --cp-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.3);
}

body.dark-mode {
    --cp-bg: #1e293b;
    --cp-sidebar-bg: #111827;
    --cp-text: #f8f9fa;
    --cp-text-muted: #94a3b8;
    --cp-border: #374151;
    --cp-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --glass-bg: rgba(30, 41, 59, 0.8);
    --glass-border: rgba(255, 255, 255, 0.05);
}

/* Modal Overlay Override */
#settings-modal.modal-overlay {
    backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
}

/* Control Panel Container */
.control-panel-container {
    display: flex;
    width: 90vw;
    max-width: 1000px;
    height: 80vh;
    background: var(--cp-bg);
    border-radius: 20px;
    box-shadow: var(--cp-shadow);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--glass-border);
    animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpFade {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Sidebar */
.cp-sidebar {
    width: 260px;
    background: var(--cp-sidebar-bg);
    border-left: 1px solid var(--cp-border);
    /* RTL */
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.cp-header {
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--cp-primary);
}

.cp-header i {
    font-size: 24px;
}

.cp-header h2 {
    font-size: 1.2rem;
    margin: 0;
    font-weight: 800;
}

.cp-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 10px;
    color: var(--cp-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.cp-nav-item:hover {
    background: rgba(13, 110, 253, 0.05);
    color: var(--cp-primary);
}

.cp-nav-item.active {
    background: var(--cp-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

/* Content Area */
.cp-content {
    flex: 1;
    padding: 30px;
    padding-bottom: 50px;
    /* Extra padding to prevent cutoff */
    overflow-y: auto;
    background: var(--cp-bg);
}

.cp-section {
    display: none;
    animation: fadeIn 0.3s ease;
    padding-bottom: 20px;
}

.cp-section.active {
    display: block !important;
    width: 100%;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cp-section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--cp-text);
    border-bottom: 2px solid var(--cp-border);
    padding-bottom: 10px;
}

/* Cards & Widgets */
.cp-card {
    background: var(--cp-bg);
    border: 1px solid var(--cp-border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.cp-card:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.cp-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--cp-text);
    font-size: 0.95rem;
}

.cp-desc {
    font-size: 0.85rem;
    color: var(--cp-text-muted);
    margin-bottom: 15px;
}

/* Custom Inputs */
.cp-input,
.cp-select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--cp-border);
    background: var(--cp-bg);
    color: var(--cp-text);
    margin-bottom: 10px;
    transition: 0.2s;
}

.cp-input:focus,
.cp-select:focus {
    border-color: var(--cp-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

/* Live Preview Box */
.live-preview-box {
    border: 2px dashed var(--cp-border);
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    background: rgba(0, 0, 0, 0.02);
    min-height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.live-preview-box img {
    max-width: 100%;
    max-height: 150px;
    object-fit: contain;
}

/* Table Themes Grid */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.theme-preview-card {
    border: 2px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: 0.2s;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.theme-preview-card.active {
    border-color: var(--cp-primary);
    transform: scale(1.05);
}

.theme-preview-img {
    height: 80px;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #888;
}

.theme-name {
    padding: 8px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: #333;
}

/* File Upload Fancy */
.cp-file-upload {
    position: relative;
    border: 2px dashed var(--cp-border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
}

.cp-file-upload:hover {
    border-color: var(--cp-primary);
    background: rgba(13, 110, 253, 0.02);
}

.cp-file-upload input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Actions */
.cp-actions {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--cp-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-cp-save {
    background: var(--cp-primary);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.btn-cp-save:hover {
    background: var(--cp-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

.btn-cp-cancel {
    background: transparent;
    color: var(--cp-text-muted);
    border: 1px solid var(--cp-border);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
}

/* Scrollbar */
.cp-content::-webkit-scrollbar {
    width: 6px;
}

.cp-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* ================= TABLE THEMES ================= */
/* Default / Standard */
.table-theme-standard thead tr {
    background: #f8f9fa;
    color: #333;
}

.table-theme-standard tbody tr:hover {
    background: #f1f1f1;
}

/* Modern Blue */
.table-theme-blue {
    border-collapse: separate;
    border-spacing: 0 5px;
}

.table-theme-blue thead tr {
    background: linear-gradient(45deg, #0d6efd, #0a58ca);
    color: white;
    border-radius: 8px;
}

.table-theme-blue th:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.table-theme-blue th:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.table-theme-blue tbody tr {
    background: #eef2ff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.table-theme-blue tbody tr:hover {
    transform: scale(1.01);
    background: #dfe7ff;
}

/* Dark Elegant */
.table-theme-dark thead tr {
    background: #1f2937;
    color: #f9fafb;
}

.table-theme-dark tbody tr:nth-child(even) {
    background: #f3f4f6;
}

.table-theme-dark tbody tr:hover {
    background: #e5e7eb;
    border-left: 4px solid #1f2937;
}

/* Minimalist */
.table-theme-minimal thead tr {
    border-bottom: 2px solid #333;
    background: transparent;
}

.table-theme-minimal th {
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.table-theme-minimal tbody tr {
    border-bottom: 1px solid #eee;
}

.table-theme-minimal tbody tr:hover {
    background: #fafafa;
}


/* ================= PRINT ASSET CARD ================= */
.print-asset-card {
    border: 1px solid var(--cp-border);
    border-radius: 12px;
    padding: 15px;
    background: #fff;
    margin-bottom: 15px;
    transition: 0.2s;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.print-asset-card:hover {
    border-color: var(--cp-primary);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.print-asset-label {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--cp-text);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.print-asset-preview {
    flex: 1;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    overflow: hidden;
    position: relative;
    border: 1px solid #eee;
}

.print-asset-preview img {
    max-width: 100%;
    max-height: 120px;
    object-fit: contain;
}

.print-asset-preview .placeholder-text {
    font-size: 12px;
    color: #999;
    text-align: center;
}

.print-asset-controls {
    display: flex;
    gap: 10px;
}

.btn-upload-asset {
    flex: 1;
    background: var(--cp-primary);
    color: white;
    border: none;
    padding: 8px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.btn-upload-asset input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.btn-reset-asset {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

body.dark-mode .print-asset-card {
    background: var(--cp-sidebar-bg);
}

/* ================= DARK MODE TABLE OVERRIDES ================= */
body.dark-mode .table-theme-standard thead tr {
    background: #374151;
    color: #f8f9fa;
}

body.dark-mode .table-theme-standard tbody tr {
    background: var(--cp-bg);
    color: #e5e7eb;
}

body.dark-mode .table-theme-standard tbody tr:hover {
    background: #374151;
}

body.dark-mode .table-theme-blue tbody tr {
    background: #1e293b;
    color: #e2e8f0;
}

body.dark-mode .table-theme-blue tbody tr:hover {
    background: #1e1b4b;
    /* Darker blue */
}

body.dark-mode .table-theme-dark tbody tr:nth-child(even) {
    background: #374151;
    color: #f3f4f6;
}

body.dark-mode .table-theme-dark tbody tr:nth-child(odd) {
    background: #1f2937;
    color: #f3f4f6;
}

body.dark-mode .table-theme-minimal thead tr {
    border-bottom: 2px solid #555;
    color: #f8f9fa;
}

body.dark-mode .table-theme-minimal tbody tr {
    border-bottom: 1px solid #444;
    color: #e5e7eb;
}

body.dark-mode .table-theme-minimal tbody tr:hover {
    background: #374151;
}

/* Fix Preview Container in Dark Mode */
body.dark-mode #table-preview-container {
    background: #1e293b;
    border-color: #4b5563 !important;
}


/* ================= TABLE HEADER CUSTOM STYLES ================= */
/* Navy Blue */
.th-navy thead tr,
.th-navy thead th {
    background-color: #000080 !important;
    background: #000080 !important;
    color: white !important;
}

/* Black */
.th-black thead tr,
.th-black thead th {
    background-color: #000000 !important;
    background: #000000 !important;
    color: white !important;
}

/* Light Cyan (User requested #add8ff) */
.th-cyan thead tr,
.th-cyan thead th {
    background-color: #add8ff !important;
    background: #add8ff !important;
    color: #000000 !important;
}

/* Grey */
.th-grey thead tr,
.th-grey thead th {
    background-color: #e9ecef !important;
    background: #e9ecef !important;
    color: #000000 !important;
}

/* White */
.th-white thead tr,
.th-white thead th {
    background-color: #ffffff !important;
    background: #ffffff !important;
    color: #000000 !important;
    border-bottom: 2px solid #dee2e6 !important;
}

/* Purple Dark */
.th-purple-deep thead tr,
.th-purple-deep thead th {
    background-color: #3f0c59 !important;
    background: #3f0c59 !important;
    color: white !important;
}

/* Burgundy */
.th-burgundy thead tr,
.th-burgundy thead th {
    background-color: #63074f !important;
    background: #63074f !important;
    color: white !important;
}

/* Pink Light */
.th-pink-bright thead tr,
.th-pink-bright thead th {
    background-color: #db7fc8 !important;
    background: #db7fc8 !important;
    color: #000 !important;
}

/* Green Dark */
.th-green-forest thead tr,
.th-green-forest thead th {
    background-color: #0d4726 !important;
    background: #0d4726 !important;
    color: white !important;
}

/* Tan/Nude */
.th-tan-nude thead tr,
.th-tan-nude thead th {
    background-color: #e0b590 !important;
    background: #e0b590 !important;
    color: #000 !important;
}


/* Color Swatches for Selection */
.header-color-swatch {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #ddd;
    display: inline-block;
    margin-right: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    vertical-align: middle;
}

.header-color-swatch:hover {
    transform: scale(1.1);
}

.header-color-swatch.active {
    border-color: var(--cp-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.3);
}

.header-color-swatch.active::after {
    content: '';
    /* Simple dot or check */
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* Dark Mode Overrides for Header Colors */
body.dark-mode .th-navy thead tr {
    background: #000050 !important;
}

body.dark-mode .th-black thead tr {
    background: #000000 !important;
    border-bottom: 1px solid #333;
}

body.dark-mode .th-cyan thead tr {
    background: #1e3a8a !important;
    /* Dark Blue for contrast with light blue intent */
    color: #fff !important;
}

body.dark-mode .th-grey thead tr {
    background: #495057 !important;
    color: #fff !important;
}

body.dark-mode .th-purple-deep thead tr {
    background: #2a083d !important;
}

body.dark-mode .th-burgundy thead tr {
    background: #4a053b !important;
}

body.dark-mode .th-pink-bright thead tr {
    background: #a55a96 !important;
    color: #fff !important;
}

body.dark-mode .th-green-forest thead tr {
    background: #08311a !important;
}

body.dark-mode .th-tan-nude thead tr {
    background: #8e735b !important;
    color: #fff !important;
}

/* Small reset button for icon BG */
.btn-small-reset {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    padding: 0;
    border-radius: 4px;
}


/* ================= ICON MANAGEMENT CARDS ================= */
.icon-mgmt-card {
    background: var(--cp-bg);
    border: 1px solid var(--cp-border);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: 0.2s;
}

.icon-mgmt-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-color: var(--cp-primary);
}

.icon-preview-box {
    width: 60px;
    height: 60px;
    background: #f8f9fa;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--cp-primary);
    border: 1px solid #eee;
    overflow: hidden;
    position: relative;
}

.icon-preview-box img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

.icon-info {
    flex: 1;
}

.icon-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--cp-text);
    margin-bottom: 2px;
}

.icon-slug {
    font-size: 11px;
    color: var(--cp-text-muted);
}

.icon-actions {
    display: flex;
    gap: 8px;
}

.btn-icon-upload {
    background: #eef2ff;
    color: #4f46e5;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

.btn-icon-upload input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.btn-icon-reset {
    background: #fff;
    color: #dc3545;
    border: 1px solid #fee2e2;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

body.dark-mode .icon-mgmt-card {
    background: var(--cp-sidebar-bg);
}

body.dark-mode .icon-preview-box {
    background: #1e293b;
    border-color: #374151;
}