/* Local Fonts - Fully Self-Hosted, Zero External Google Requests */
@font-face {
    font-family: 'Cairo';
    font-style: normal;
    font-weight: 200 1000;
    font-display: swap;
    src: url('fonts/Cairo-Variable.ttf') format('truetype');
}

@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/Outfit-400.ttf') format('truetype');
}

@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('fonts/Outfit-600.ttf') format('truetype');
}

@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('fonts/Outfit-700.ttf') format('truetype');
}

@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('fonts/Outfit-800.ttf') format('truetype');
}

/* CSS Variables & Theme Definitions */
:root {
    /* Fonts - Cairo is primary */
    --font-ar: 'Cairo', system-ui, -apple-system, sans-serif;
    --font-en: 'Outfit', system-ui, -apple-system, sans-serif;

    /* Theme colors */
    --color-blue-dark: #163E64;
    --color-blue-light: #215F9A;
    
    /* Common Transitions */
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-elastic: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Dark Theme (Default) - Strictly Greys and Approved Blues */
.dark-theme {
    --bg-primary: #0f131a; /* Dark grey-blue */
    --text-primary: #f1f5f9; /* Light grey */
    --text-secondary: #94a3b8; /* Medium grey */
    --text-muted: #475569; /* Darker grey */
    
    /* Glassmorphism Styles */
    --glass-bg: rgba(22, 28, 38, 0.6);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-border-hover: rgba(33, 95, 154, 0.3);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.25);
    --glass-shadow-hover: 0 12px 40px 0 rgba(16, 62, 100, 0.15);

    /* Orb Colors (Soft glows using approved colors) */
    --orb-color-1: rgba(22, 62, 100, 0.25); /* #163E64 */
    --orb-color-2: rgba(33, 95, 154, 0.15); /* #215F9A */
    --orb-color-3: rgba(71, 85, 105, 0.12);  /* Medium grey */

    /* Active Accent color */
    --accent-color: var(--color-blue-light);
    --accent-color-hover: var(--color-blue-dark);
    --accent-bg-alpha: rgba(33, 95, 154, 0.1);
    
    --header-bg: rgba(15, 19, 26, 0.85);
    --button-bg: rgba(255, 255, 255, 0.05);
    --button-hover: rgba(255, 255, 255, 0.1);
}

/* Light Theme - Strictly Greys and Approved Blues */
.light-theme {
    --bg-primary: #f8fafc; /* Very light grey */
    --text-primary: #0f172a; /* Dark grey */
    --text-secondary: #475569; /* Medium grey */
    --text-muted: #94a3b8; /* Light grey */
    
    /* Glassmorphism Styles */
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(15, 23, 42, 0.08);
    --glass-border-hover: rgba(33, 95, 154, 0.3);
    --glass-shadow: 0 8px 32px 0 rgba(15, 23, 42, 0.03);
    --glass-shadow-hover: 0 12px 40px 0 rgba(33, 95, 154, 0.1);

    /* Orb Colors (Soft glows using approved colors) */
    --orb-color-1: rgba(33, 95, 154, 0.08); /* #215F9A */
    --orb-color-2: rgba(22, 62, 100, 0.05);  /* #163E64 */
    --orb-color-3: rgba(148, 163, 184, 0.15); /* Light grey */

    /* Active Accent color */
    --accent-color: var(--color-blue-dark);
    --accent-color-hover: var(--color-blue-light);
    --accent-bg-alpha: rgba(22, 62, 100, 0.08);

    --header-bg: rgba(248, 250, 252, 0.85);
    --button-bg: rgba(15, 23, 42, 0.05);
    --button-hover: rgba(15, 23, 42, 0.1);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-ar);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Background Mesh & Orbs */
.mesh-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.mesh-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    mix-blend-mode: normal;
    transition: var(--transition-smooth);
}

.orb-1 {
    top: -10%;
    right: -10%;
    width: 50vw;
    height: 50vw;
    background-color: var(--orb-color-1);
    animation: float-slow 25s infinite alternate ease-in-out;
}

.orb-2 {
    bottom: -20%;
    left: -10%;
    width: 60vw;
    height: 60vw;
    background-color: var(--orb-color-2);
    animation: float-slow 30s infinite alternate-reverse ease-in-out;
}

.orb-3 {
    top: 40%;
    left: 30%;
    width: 40vw;
    height: 40vw;
    background-color: var(--orb-color-3);
    animation: float-slow 20s infinite alternate ease-in-out;
}

@keyframes float-slow {
    0% {
        transform: translate(0, 0) scale(1);
    }
    50% {
        transform: translate(-5%, 8%) scale(1.1);
    }
    100% {
        transform: translate(8%, -5%) scale(0.95);
    }
}

/* Layout Container */
.app-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    height: 160px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition-smooth);
}

/* Municipality Logo badge style */
.logo-area {
    display: flex;
    align-items: center;
}

.muni-logo {
    height: 144px;
    width: auto;
    object-fit: contain;
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    border: none;
    transition: var(--transition-smooth);
}

/* Dark Mode logo adjustment for transparent background */
.dark-theme .muni-logo {
    filter: invert(1) hue-rotate(180deg);
}

.header-actions button {
    background: var(--button-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.header-actions button:hover {
    background: var(--button-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.header-actions button svg {
    width: 20px;
    height: 20px;
}

/* Hide theme icons based on current active theme */
.dark-theme .sun-icon { display: block; }
.dark-theme .moon-icon { display: none; }
.light-theme .sun-icon { display: none; }
.light-theme .moon-icon { display: block; }

/* Main Content & Hero */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem 0;
}

.hero {
    text-align: center;
    margin-bottom: 3.5rem;
}

/* Centered DRMHub Title */
.hub-main-title {
    font-family: var(--font-en);
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -1.5px;
    line-height: 1;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, var(--color-blue-light), var(--color-blue-dark));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(33, 95, 154, 0.15));
}

.hero h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Animations */
.animate-fade-in {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-fade-in-delayed {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.15s;
}

.animate-fade-in-more-delayed {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.3s;
}

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

/* Grid Container & Cards (Optimized for 5 systems) */
.grid-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem;
    perspective: 1000px;
}

.card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    cursor: pointer;
    transition: var(--transition-elastic);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 340px;
    flex: 0 1 calc(33.333% - 1.5rem);
    min-width: 320px;
    max-width: 380px;
}

.card-inner {
    padding: 2.25rem;
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 2;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
}

/* Status Badge with blue pulse */
.status-badge {
    background: var(--accent-bg-alpha);
    color: var(--accent-color);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid rgba(33, 95, 154, 0.15);
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: var(--accent-color);
    border-radius: 50%;
    display: inline-block;
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(33, 95, 154, 0.5);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(33, 95, 154, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(33, 95, 154, 0);
    }
}

/* Card Icons */
.card-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent-bg-alpha);
    color: var(--accent-color);
    transition: var(--transition-elastic);
}

.card-icon svg {
    width: 28px;
    height: 28px;
    transition: var(--transition-elastic);
}

/* Card Body text styling */
.card-body {
    flex-grow: 1;
}

.card-body h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    transition: var(--transition-fast);
    line-height: 1.4;
}

.card-body p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    font-weight: 400;
}

/* Card Footer */
.card-footer {
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
}

.action-btn {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-fast);
}

.arrow-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* CARD HOVER STATES & GLOWS (Exclusive Blue/Grey theme) */
.card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--glass-shadow-hover);
    border-color: var(--glass-border-hover);
}

.card:hover .card-icon {
    background-color: var(--accent-color);
    color: #ffffff;
    transform: rotate(-10deg) scale(1.1);
}

.card:hover h3 {
    color: var(--accent-color);
}

/* Arrow movements in RTL on card hover */
.card:hover .arrow-icon {
    transform: translateX(-6px);
}

/* Decorative card shine effect */
.card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0) 70%);
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
    z-index: 1;
}

.card:hover::after {
    opacity: 1;
}

/* Footer styling */
.footer {
    padding: 2.5rem 0;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer p {
    font-weight: 500;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition-fast);
    font-weight: 600;
}

.footer-links a:hover {
    color: var(--text-primary);
}

.footer-links span {
    opacity: 0.3;
}

/* Responsive adjustments */
@media (max-width: 1080px) {
    .grid-container {
        gap: 1.5rem;
    }
    .card {
        flex: 0 1 calc(50% - 1rem);
        max-width: none;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 0 1.25rem;
    }
    
    .header {
        height: 136px;
    }

    .logo-area {
        margin-top: 0;
    }

    .muni-logo {
        height: 120px;
    }

    .hero {
        margin-bottom: 2.5rem;
    }

    .hub-main-title {
        font-size: 2.75rem;
    }

    .hero h2 {
        font-size: 1.65rem;
    }

    .hero p {
        font-size: 0.95rem;
    }

    .grid-container {
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
    }

    .card {
        min-height: 280px;
        flex: 1 1 auto;
        width: 100%;
    }

    .card-inner {
        padding: 1.75rem;
    }

    .footer {
        flex-direction: column;
        gap: 1.25rem;
        text-align: center;
        padding: 2rem 0;
    }
}

/* =======================================================
   Versioning & Cache Busting Elements & Update Modal
   ======================================================= */

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.version-control-area {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.version-badge-container {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--button-bg);
    border: 1px solid var(--glass-border);
    padding: 0.4rem 0.85rem;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: var(--transition-fast);
}

.version-badge-container:hover {
    border-color: var(--glass-border-hover);
}

.version-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.version-badge {
    font-family: var(--font-en);
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--accent-color);
    letter-spacing: 0.5px;
}

/* Update Notification Trigger Button */
.update-notify-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.35);
    padding: 0.4rem 0.85rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 800;
    font-family: var(--font-ar);
    cursor: pointer;
    animation: updatePulse 2s infinite ease-in-out;
    transition: var(--transition-fast);
}

.dark-theme .update-notify-btn {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.4);
}

.light-theme .update-notify-btn {
    background: #fef3c7;
    color: #92400e;
    border-color: #fcd34d;
}

.update-notify-btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.25);
}

.update-icon {
    width: 15px;
    height: 15px;
}

@keyframes updatePulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    50% { transform: scale(1.02); box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* Modal Overlay & Card (System Update Confirmation Dialog - 100% Cairo) */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(10, 15, 25, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: fadeInModal 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: var(--bg-primary);
    border: 1px solid var(--glass-border-hover);
    border-radius: 28px;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.5);
    max-width: 480px;
    width: 100%;
    overflow: hidden;
    font-family: var(--font-ar);
    direction: rtl;
    text-align: right;
    animation: slideUpModal 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUpModal {
    from { opacity: 0; transform: translateY(25px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    background: linear-gradient(135deg, var(--color-blue-dark), #0b2545);
    padding: 1.4rem 1.6rem;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-icon-badge {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: #f59e0b;
    color: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.modal-icon-badge svg {
    width: 24px;
    height: 24px;
}

.modal-header-text h3 {
    font-size: 1.15rem;
    font-weight: 800;
    margin-bottom: 0.15rem;
}

.modal-header-text p {
    font-size: 0.8rem;
    font-weight: 600;
    color: #7dd3fc;
}

.modal-body {
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.modal-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    font-weight: 500;
}

.modal-alert-box {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 16px;
    padding: 1rem 1.2rem;
    font-size: 0.82rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.dark-theme .modal-alert-box {
    color: #fef3c7;
}

.light-theme .modal-alert-box {
    color: #92400e;
}

.alert-info-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    line-height: 1.5;
    font-weight: 600;
}

.version-diff-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    padding-top: 0.4rem;
    border-top: 1px dashed rgba(245, 158, 11, 0.25);
}

.diff-arrow {
    font-size: 1rem;
}

.highlight-version {
    color: #10b981;
    font-family: var(--font-en);
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-top: 0.5rem;
}

.btn-primary-update {
    flex: 1;
    padding: 0.85rem 1.25rem;
    background: linear-gradient(135deg, var(--color-blue-light), var(--color-blue-dark));
    color: #ffffff;
    font-family: var(--font-ar);
    font-size: 0.9rem;
    font-weight: 800;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    box-shadow: 0 4px 16px rgba(22, 62, 100, 0.35);
    transition: var(--transition-fast);
}

.btn-primary-update:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(33, 95, 154, 0.45);
}

.btn-primary-update:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary-cancel {
    padding: 0.85rem 1.5rem;
    background: var(--button-bg);
    color: var(--text-secondary);
    font-family: var(--font-ar);
    font-size: 0.9rem;
    font-weight: 700;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-secondary-cancel:hover {
    background: var(--button-hover);
    color: var(--text-primary);
}

.spin-icon {
    width: 18px;
    height: 18px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}
