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

:root {
  --primary: #6366f1;
  --secondary: #a855f7;
  --dark-bg: #0f172a;
  --dark-surface: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --accent: #ec4899;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Tajawal', sans-serif;
  background-color: var(--dark-bg);
  color: var(--text-main);
  line-height: 1.6;
  direction: rtl;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Background Animated Gradient blobs */
body::before, body::after {
  content: '';
  position: absolute;
  width: 50vw;
  height: 50vw;
  border-radius: 50%;
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
  opacity: 0.15;
  z-index: -1;
  animation: float 15s infinite alternate ease-in-out;
}
body::after {
  background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
  right: -20vw;
  top: 30vh;
  animation-delay: -5s;
}

/* Glassmorphism Classes */
.glass-panel {
  background: var(--dark-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.glass-header {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Typography & Utilities */
h1, h2, h3, h4, h5 {
  font-weight: 700;
  color: #fff;
}
.text-gradient {
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-family: 'Tajawal', sans-serif;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.3s ease;
  text-decoration: none;
  text-align: center;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}
/* Form Controls */
.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    font-family: 'Tajawal', sans-serif;
    outline: none;
    transition: all 0.3s ease;
}
.form-control:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
}
select.form-control option {
    background-color: #1e1e2d;
    color: #ffffff;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}
.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border-right: 4px solid #ef4444;
  color: #fca5a5;
}

/* Keyframes */
@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-30px, 50px) scale(1.1); }
  100% { transform: translate(30px, -50px) scale(0.9); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in-up {
  animation: fadeInUp 0.6s ease-out forwards;
}

/* Layout Utilities */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 150px);
  padding: 2rem;
}
.login-box {
  width: 100%;
  max-width: 450px;
  padding: 3rem;
}

.dashboard-container {
  display: flex;
  min-height: calc(100vh - 80px);
}
.sidebar {
  width: 250px;
  background: var(--dark-surface);
  border-left: 1px solid var(--glass-border);
  padding: 2rem 1rem;
}
.main-content {
  flex: 1;
  padding: 2rem;
  min-width: 0;
  max-width: 100%;
}

/* Footer Styles */
.main-footer {
    margin-top: 5rem;
    background: var(--dark-surface);
    border-top: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden;
}

.main-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), var(--secondary), transparent);
    opacity: 0.5;
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 3rem;
    padding: 3rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.footer-section {
    flex: 1;
    min-width: 280px;
    display: flex;
    flex-direction: column;
}

.footer-section h3 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    display: inline-block;
}

.contact-info-list {
    list-style: none;
    padding: 0;
    width: 100%;
}

.contact-info-list li {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: all 0.3s ease;
}

.contact-info-list li:last-child {
    border-bottom: none;
}

.contact-info-list li:hover {
    transform: translateX(-5px);
    background: rgba(255,255,255,0.02);
    border-radius: 0.5rem;
    padding-right: 0.5rem;
}

.contact-icon-wrapper {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    margin-left: 1rem;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.contact-info-list li:hover .contact-icon-wrapper {
    background: var(--primary);
    color: #fff;
}

.contact-info-list li span, .contact-info-list li a {
    color: var(--text-main);
    font-size: 1.1rem;
    text-decoration: none;
    transition: color 0.3s ease;
}

.contact-info-list li a.whatsapp-link:hover {
    color: #25d366 !important;
}

.social-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.social-icon {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    color: var(--text-main);
    font-size: 1.2rem;
    text-decoration: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.social-icon::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.social-icon:hover {
    transform: translateY(-5px) scale(1.1);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.social-icon:hover::before {
    opacity: 1;
}

.social-icon[title="فيسبوك"]:hover { background: #1877F2; }
.social-icon[title="فيسبوك"]:hover::before { opacity: 0; }
.social-icon[title="تويتر / X"]:hover { background: #000000; border-color: #333; }
.social-icon[title="تويتر / X"]:hover::before { opacity: 0; }
.social-icon[title="إنستغرام"]:hover { background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); }
.social-icon[title="إنستغرام"]:hover::before { opacity: 0; }
.social-icon[title="يوتيوب"]:hover { background: #FF0000; }
.social-icon[title="يوتيوب"]:hover::before { opacity: 0; }
.social-icon[title="تيليغرام"]:hover { background: #0088cc; }
.social-icon[title="تيليغرام"]:hover::before { opacity: 0; }

.footer-bottom {
    background: rgba(0,0,0,0.2);
    padding: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.dev-name {
    transition: all 0.3s ease;
    display: inline-block;
}

.dev-name:hover {
    transform: scale(1.05);
}

.dark-mode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    color: var(--text-main);
    text-decoration: none;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
    cursor: pointer;
}

.dark-mode-btn:hover {
    background: var(--primary);
    color: #fff;
    transform: rotate(30deg);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
}

/* Mobile Responsiveness */
@media screen and (max-width: 900px) {
    .dashboard-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-left: none;
        border-bottom: 1px solid var(--glass-border);
        padding: 1rem;
    }
    
    .main-content {
        padding: 1rem;
        width: 100%;
        overflow-x: hidden;
    }
    
    .glass-header .container {
        flex-direction: column;
        justify-content: center;
        text-align: center;
        gap: 1.5rem;
    }
    
    .main-nav {
        flex-direction: column;
        width: 100%;
    }
    
    .main-nav .btn, .main-nav form {
        width: 100%;
        margin-right: 0 !important;
        margin-bottom: 0.5rem;
    }
    
    /* Ensure tables can be horizontally scrolled instead of breaking layout */
    table {
        min-width: 600px;
    }
    
    .glass-panel {
        padding: 1.5rem 1rem !important;
        overflow-x: auto; /* Always allow horizontal scroll on panels for mobile */
    }
    
    body::before, body::after {
        width: 100vw;
        height: 100vw;
        opacity: 0.1;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
    
    .contact-info-list li {
        justify-content: center;
    }
    
    .social-links {
        justify-content: center;
    }
}

/* ----------------------------------------------------
 * High-Fidelity Print & PDF Styles (A4 Landscape Formats)
 * ---------------------------------------------------- */
@media print {
    @page {
        size: A4 landscape;
        margin: 15mm;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-family: 'Tajawal', 'Arial', sans-serif !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    body::before, body::after, .blob {
        display: none !important;
    }

    /* Hide UI controls */
    .sidebar, .glass-header, .presentation-tools, .btn, form, footer, .alert {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    /* Display the injected print header only during print */
    #official_print_header {
        display: block !important;
        text-align: center;
        page-break-after: avoid;
    }

    /* Style the panels as clean data sections */
    .glass-panel {
        background: #ffffff !important;
        border: 2px solid #cbd5e1 !important;
        box-shadow: none !important;
        color: #0f172a !important;
        page-break-inside: avoid;
        margin-bottom: 2rem !important;
        padding: 1.5rem !important;
        border-radius: 8px !important;
    }

    /* Text elements */
    .text-gradient {
        background: none !important;
        -webkit-text-fill-color: #0f172a !important;
        color: #0f172a !important;
        text-align: center;
        border-bottom: 2px solid #e2e8f0;
        padding-bottom: 10px;
        margin-bottom: 20px !important;
    }

    h2, h3, p, div {
        color: #000000 !important;
    }

    /* Ensure tables don't get cut off and print nicely */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        border: 2px solid #1e293b !important;
        page-break-inside: auto;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    th {
        background-color: #f1f5f9 !important;
        color: #000000 !important;
        border: 1px solid #94a3b8 !important;
        padding: 10px !important;
        font-weight: bold !important;
        border-bottom: 2px solid #000 !important;
    }

    td {
        border: 1px solid #cbd5e1 !important;
        padding: 8px !important;
        color: #000000 !important;
    }
    
    tr:nth-child(even) td {
        background-color: #f8fafc !important;
    }

    /* Grid Layouts to Flex or proper blocks for print */
    .responsive-grid, div[style*="display: grid"], div[style*="display:grid"] {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 15px !important;
        justify-content: center !important;
    }

    .responsive-grid > div, div[style*="display: grid"] > div, div[style*="display:grid"] > div {
        flex: 1 1 30% !important;
        min-width: 150px !important;
        border: 2px solid #cbd5e1 !important;
        border-radius: 8px !important;
        background: #f8fafc !important;
    }

    /* Charts sizing */
    canvas {
        max-width: 100% !important;
        height: auto !important;
        max-height: 400px !important;
        page-break-inside: avoid;
        margin: 0 auto !important;
        display: block !important;
    }
}
