/* =============================================================================
   CTPL CRM — Admin Custom Styles
   Brand: #0D2137 (Deep Navy), #2E8BC0 (Tech Blue), #1A4B6E (Secondary), #5DADE2 (Accent)
   Fonts: Inter (body), Poppins (headings)
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Poppins:wght@600;700;800&display=swap');

/* =============================================================================
   1. BRANDED LOGIN PAGE
   ============================================================================= */

body.ctpl-login {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0D2137;
    min-height: 100vh;
}

body.ctpl-login header,
body.ctpl-login nav,
body.ctpl-login #nav-sidebar,
body.ctpl-login aside {
    display: none !important;
}

.ctpl-login-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* --- Left Brand Panel --- */
.ctpl-login-brand {
    flex: 1;
    background: linear-gradient(135deg, #0D2137 0%, #1A4B6E 50%, #0D2137 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 2rem;
}

.ctpl-login-brand-inner {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 460px;
    width: 100%;
    padding-bottom: 3rem;
}

/* Animated orbit rings */
.ctpl-orbit {
    position: absolute;
    border-radius: 50%;
    border: 2px solid rgba(46, 139, 192, 0.25);
    animation: ctpl-orbit-spin 20s linear infinite;
}

.ctpl-orbit-1 {
    width: 300px;
    height: 300px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-color: rgba(46, 139, 192, 0.22);
    animation-duration: 25s;
}

.ctpl-orbit-2 {
    width: 450px;
    height: 450px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-color: rgba(93, 173, 226, 0.16);
    animation-duration: 35s;
    animation-direction: reverse;
}

.ctpl-orbit-3 {
    width: 600px;
    height: 600px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-color: rgba(46, 139, 192, 0.10);
    animation-duration: 45s;
}

@keyframes ctpl-orbit-spin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Central sphere glow */
.ctpl-sphere {
    position: absolute;
    width: 220px;
    height: 220px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%,
        rgba(93, 173, 226, 0.4) 0%,
        rgba(46, 139, 192, 0.25) 40%,
        rgba(13, 33, 55, 0.15) 70%,
        transparent 100%);
    box-shadow: 0 0 60px rgba(46, 139, 192, 0.2), 0 0 120px rgba(93, 173, 226, 0.1);
    animation: ctpl-sphere-pulse 4s ease-in-out infinite alternate;
}

@keyframes ctpl-sphere-pulse {
    from { opacity: 0.7; transform: translate(-50%, -50%) scale(1); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

/* Brand content */
.ctpl-brand-content {
    position: relative;
    z-index: 3;
}

.ctpl-login-logo {
    width: 140px;
    height: 140px;
    object-fit: contain;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.ctpl-brand-title {
    font-family: 'Poppins', sans-serif;
    font-size: 2.2rem;
    font-weight: 800;
    color: #ffffff;
    margin: 0 0 0.5rem;
    letter-spacing: -0.02em;
}

.ctpl-brand-tagline {
    font-size: 1rem;
    color: rgba(93, 173, 226, 0.9);
    margin: 0 0 2.5rem;
    font-weight: 300;
}

/* Feature items */
.ctpl-brand-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    text-align: left;
}

.ctpl-feature-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.9rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(46, 139, 192, 0.15);
    border-radius: 10px;
    backdrop-filter: blur(4px);
    transition: background 0.2s;
}

.ctpl-feature-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.ctpl-feature-item .material-symbols-outlined {
    font-size: 1.2rem;
    color: #5DADE2;
}

.ctpl-feature-item span:last-child {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 400;
}

/* Brand footer */
.ctpl-brand-footer {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

.ctpl-brand-footer p {
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.75rem;
    margin: 0;
}

/* --- Right Login Form Panel --- */
.ctpl-login-form-panel {
    flex: 0 0 520px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    padding: 2rem;
    position: relative;
}

.ctpl-login-form-container {
    width: 100%;
    max-width: 380px;
}

/* Login header */
.ctpl-login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.ctpl-login-form-logo-link {
    display: inline-block;
    margin-bottom: 1.25rem;
    transition: transform 0.2s ease;
}

.ctpl-login-form-logo-link:hover {
    transform: scale(1.05);
}

.ctpl-login-form-logo {
    width: 180px;
    height: 180px;
    object-fit: contain;
}

.ctpl-login-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #0D2137, #2E8BC0);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    box-shadow: 0 8px 24px rgba(13, 33, 55, 0.25);
}

.ctpl-login-icon .material-symbols-outlined {
    font-size: 1.6rem;
    color: #ffffff;
}

.ctpl-login-header h2 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: #0D2137;
    margin: 0 0 0.35rem;
}

.ctpl-login-header p {
    color: #6b7280;
    font-size: 0.9rem;
    margin: 0;
}

/* Error messages */
.ctpl-login-errors {
    margin-bottom: 1.5rem;
}

.ctpl-error-msg {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    color: #dc2626;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.ctpl-error-msg:last-child {
    margin-bottom: 0;
}

.ctpl-error-msg .material-symbols-outlined {
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* Form fields */
.ctpl-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.ctpl-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.ctpl-field label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ctpl-field label .material-symbols-outlined {
    font-size: 1rem;
    color: #2E8BC0;
}

.ctpl-field input[type="text"],
.ctpl-field input[type="password"] {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    color: #1f2937;
    background: #f9fafb;
    transition: all 0.2s ease;
    outline: none;
    box-sizing: border-box;
}

.ctpl-field input:focus {
    border-color: #2E8BC0;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(46, 139, 192, 0.12);
}

.ctpl-field input::placeholder {
    color: #9ca3af;
}

/* Login button */
.ctpl-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.85rem 1.5rem;
    margin-top: 0.5rem;
    background: linear-gradient(135deg, #0D2137, #1A4B6E);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 16px rgba(13, 33, 55, 0.3);
}

.ctpl-login-btn:hover {
    background: linear-gradient(135deg, #1A4B6E, #2E8BC0);
    box-shadow: 0 6px 24px rgba(46, 139, 192, 0.35);
    transform: translateY(-1px);
}

.ctpl-login-btn:active {
    transform: translateY(0);
}

.ctpl-login-btn .material-symbols-outlined {
    font-size: 1.2rem;
    transition: transform 0.2s;
}

.ctpl-login-btn:hover .material-symbols-outlined {
    transform: translateX(3px);
}

/* Footer links */
.ctpl-login-footer-links {
    margin-top: 2rem;
    text-align: center;
}

.ctpl-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #6b7280;
    font-size: 0.85rem;
    text-decoration: none;
    transition: color 0.2s;
}

.ctpl-back-link:hover {
    color: #2E8BC0;
}

.ctpl-back-link .material-symbols-outlined {
    font-size: 1rem;
    transition: transform 0.2s;
}

.ctpl-back-link:hover .material-symbols-outlined {
    transform: translateX(-3px);
}

/* --- Login Responsive --- */
@media (max-width: 960px) {
    .ctpl-login-wrapper {
        flex-direction: column;
    }

    .ctpl-login-brand {
        flex: none;
        padding: 2.5rem 1.5rem;
        min-height: auto;
    }

    .ctpl-orbit { display: none; }
    .ctpl-sphere { display: none; }

    .ctpl-brand-features {
        grid-template-columns: 1fr 1fr;
    }

    .ctpl-login-form-panel {
        flex: 1;
        padding: 2rem 1.5rem;
    }

    .ctpl-brand-footer {
        position: relative;
        bottom: auto;
        left: auto;
        transform: none;
        margin-top: 2rem;
    }
}

@media (max-width: 520px) {
    .ctpl-brand-features {
        grid-template-columns: 1fr;
    }

    .ctpl-brand-title {
        font-size: 1.6rem;
    }
}


/* =============================================================================
   2. CRM DASHBOARD — Header & KPI Cards
   ============================================================================= */

.crm-dashboard-title {
    font-family: 'Poppins', sans-serif !important;
    font-size: 1.8rem !important;
    font-weight: 700 !important;
    color: #0D2137;
    margin: 0 0 0.25rem;
}

.crm-dashboard-subtitle {
    color: #6b7280;
    font-size: 0.95rem;
    margin: 0;
}

.dark .crm-dashboard-title,
[data-theme="dark"] .crm-dashboard-title {
    color: #f1f5f9;
}

.dark .crm-dashboard-subtitle,
[data-theme="dark"] .crm-dashboard-subtitle {
    color: #94a3b8;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: #ffffff;
    border-radius: 14px;
    padding: 1.3rem 1.4rem;
    box-shadow: 0 1px 4px rgba(13, 33, 55, 0.06), 0 0 0 1px rgba(13, 33, 55, 0.04);
    border-left: 4px solid;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    opacity: 0.04;
    transform: translate(20px, -20px);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(13, 33, 55, 0.1), 0 0 0 1px rgba(13, 33, 55, 0.06);
}

.kpi-card.blue { border-left-color: #2E8BC0; }
.kpi-card.blue::after { background: #2E8BC0; }
.kpi-card.green { border-left-color: #059669; }
.kpi-card.green::after { background: #059669; }
.kpi-card.amber { border-left-color: #d97706; }
.kpi-card.amber::after { background: #d97706; }
.kpi-card.red { border-left-color: #dc2626; }
.kpi-card.red::after { background: #dc2626; }
.kpi-card.purple { border-left-color: #7c3aed; }
.kpi-card.purple::after { background: #7c3aed; }
.kpi-card.cyan { border-left-color: #0891b2; }
.kpi-card.cyan::after { background: #0891b2; }

.kpi-card .kpi-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    opacity: 0.6;
}

.kpi-card .kpi-value {
    font-family: 'Poppins', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    color: #0D2137;
}

.kpi-card .kpi-title {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.kpi-card .kpi-subtitle {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.15rem;
}

/* KPI Card Links */
.kpi-card-link {
    text-decoration: none !important;
    color: inherit !important;
    display: block;
    cursor: pointer;
}

.kpi-card-link .kpi-card {
    cursor: pointer;
}

.kpi-card-link:hover .kpi-card {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(13, 33, 55, 0.1), 0 0 0 1px rgba(13, 33, 55, 0.06);
}

/* Activity Card Header Links */
.activity-card-header-link {
    text-decoration: none !important;
    color: inherit !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.activity-card-header-link:hover {
    color: #2E8BC0 !important;
}

/* =============================================================================
   3. CRM DASHBOARD — Charts
   ============================================================================= */

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    background: #ffffff;
    border-radius: 14px;
    padding: 1.4rem;
    box-shadow: 0 1px 4px rgba(13, 33, 55, 0.06), 0 0 0 1px rgba(13, 33, 55, 0.04);
}

.chart-card h3 {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: #0D2137;
    margin: 0 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-card h3 .material-symbols-outlined {
    font-size: 1.1rem;
    color: #2E8BC0;
}

/* =============================================================================
   4. CRM DASHBOARD — Activity Tables
   ============================================================================= */

.activity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.activity-card {
    background: #ffffff;
    border-radius: 14px;
    padding: 1.4rem;
    box-shadow: 0 1px 4px rgba(13, 33, 55, 0.06), 0 0 0 1px rgba(13, 33, 55, 0.04);
}

.activity-card h3 {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: #0D2137;
    margin: 0 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.activity-card h3 .material-symbols-outlined {
    font-size: 1.1rem;
    color: #2E8BC0;
}

.activity-table {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: collapse;
}

.activity-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    color: #6b7280;
    font-weight: 600;
    border-bottom: 2px solid #f0f4f8;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.activity-table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid #f5f7fa;
    color: #374151;
}

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

.activity-table a {
    color: #2E8BC0;
    text-decoration: none;
    font-weight: 500;
}

.activity-table a:hover {
    color: #0D2137;
    text-decoration: underline;
}

/* =============================================================================
   5. CRM DASHBOARD — Quick Actions
   ============================================================================= */

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.quick-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1.1rem;
    background: linear-gradient(135deg, #f0f7fc, #e8f4f8);
    color: #0D2137;
    border: 1px solid rgba(46, 139, 192, 0.15);
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.quick-action-btn:hover {
    background: linear-gradient(135deg, #2E8BC0, #1A4B6E);
    color: #ffffff;
    text-decoration: none;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(46, 139, 192, 0.25);
    transform: translateY(-1px);
}

.quick-action-btn .material-symbols-outlined {
    font-size: 1rem;
}

/* =============================================================================
   6. Status Badges (used across admin list views)
   ============================================================================= */

.badge-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    letter-spacing: 0.02em;
}

/* =============================================================================
   7. GLOBAL CRM OVERRIDES — Unfold theme enhancements
   ============================================================================= */

/* Use brand fonts globally in admin */
[data-theme] body,
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

/* Sidebar logo — handled via template override */

/* Sidebar branding */
aside nav a.is-active,
aside nav a:hover {
    color: #2E8BC0;
}

/* Improve table readability */
#result_list th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Form fieldsets */
fieldset h2 {
    font-family: 'Poppins', sans-serif !important;
    font-weight: 600 !important;
}

/* =============================================================================
   8. DARK MODE SUPPORT
   ============================================================================= */

.dark .kpi-card,
[data-theme="dark"] .kpi-card {
    background: #1a2332;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.dark .kpi-card .kpi-value,
[data-theme="dark"] .kpi-card .kpi-value {
    color: #f1f5f9;
}

.dark .kpi-card .kpi-title,
[data-theme="dark"] .kpi-card .kpi-title {
    color: #94a3b8;
}

.dark .chart-card,
.dark .activity-card,
[data-theme="dark"] .chart-card,
[data-theme="dark"] .activity-card {
    background: #1a2332;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.dark .chart-card h3,
.dark .activity-card h3,
[data-theme="dark"] .chart-card h3,
[data-theme="dark"] .activity-card h3 {
    color: #e2e8f0;
}

.dark .activity-table th,
[data-theme="dark"] .activity-table th {
    color: #94a3b8;
    border-bottom-color: #2d3748;
}

.dark .activity-table td,
[data-theme="dark"] .activity-table td {
    color: #cbd5e1;
    border-bottom-color: #1e293b;
}

.dark .activity-table a,
[data-theme="dark"] .activity-table a {
    color: #5DADE2;
}

.dark .quick-action-btn,
[data-theme="dark"] .quick-action-btn {
    background: linear-gradient(135deg, #1e293b, #1a2332);
    color: #e2e8f0;
    border-color: rgba(93, 173, 226, 0.15);
}

.dark .quick-action-btn:hover,
[data-theme="dark"] .quick-action-btn:hover {
    background: linear-gradient(135deg, #2E8BC0, #1A4B6E);
    color: #ffffff;
    border-color: transparent;
}

/* =============================================================================
   9. RESPONSIVE
   ============================================================================= */

@media (max-width: 768px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .activity-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}
