/**
 * MADIAD V2 Theme - Main Stylesheet
 * Global styles, color system, footer and base components
 * Optimized version - removed header conflicts
 * FIXED: Submenu toggle button perfect alignment
 * FIXED: Accessibility contrast ratios + removed footer whitespace
 */

/* ===================================
   CSS Variables - Color System
   =================================== */
:root {
    /* Primary Colors */
    --color-primary: #DC143C;
    --color-primary-dark: #B91C3C;
    --color-primary-light: #E63946;
    
    /* Neutral Colors */
    --color-charcoal: #1A1A1A;
    --color-dark-gray: #2D2D2D;
    --color-medium-gray: #4A4A4A;
    --color-light-gray: #6C6C6C;
    --color-soft-gray: #9B9B9B;
    --color-bg-gray: #F5F5F7;
    --color-bg-secondary: #F8F9FA;
    --color-bg-tertiary: #F0F2F5;
    --color-white: #FFFFFF;
    
    /* Dark Theme Colors */
    --color-dark-bg: #0F1419;
    --color-dark-bg-secondary: #1A1D23;
    
    /* Secondary Colors */
    --color-blue: #1E3A8A;
    --color-green: #10B981;
    --color-amber: #F59E0B;
    --color-purple: #7C3AED;
    
    /* Text Colors */
    --text-primary: #2D2D2D;
    --text-secondary: #6C6C6C;
    --text-on-dark: #F5F5F7;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 10px 30px rgba(0, 0, 0, 0.15);
    --shadow-glow: 0 0 20px rgba(220, 20, 60, 0.3);
    
    /* Borders */
    --border-color: rgba(0, 0, 0, 0.06);
    --border-radius-sm: 6px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 20px;
    
    /* Spacing */
    --section-padding: 100px 0;
    --section-padding-mobile: 60px 0;
    
    /* Fonts */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'IBM Plex Sans', var(--font-primary);
    
    /* MADIAD Theme Specific */
    --madiad-primary: #DC143C;
    --madiad-secondary: #333333;
    --madiad-text: #666666;
    --madiad-light-gray: #f8f9fa;
    --madiad-white: #ffffff;
    --madiad-black: #000000;
    --font-body: 'Inter', sans-serif;
    transition: background 0.3s ease, border-color 0.3s ease;
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --spacing-xxl: 4rem;
    
    /* Z-index Management */
    --z-index-dropdown: 100;
    --z-index-sticky: 500;
    --z-index-tooltip: 600;
    --z-index-fixed: 700;
    --z-index-modalbackdrop: 800;
    --z-index-modal: 900;
    --z-index-header: 9000;
    --z-index-mobile-overlay: 100000;
    --z-index-mobile-menu: 100001;
}

/* ===================================
   Reset & Base Styles
   =================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-primary);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--color-white);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 1rem;
}

h1 { font-size: 3rem; }
h2 { font-size: 2.5rem; }
h3 { font-size: 2rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin: 0 0 1rem;
    line-height: 1.6;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--color-primary-dark);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===================================
   Layout Components
   =================================== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.section {
    padding: var(--section-padding);
}

@media (max-width: 768px) {
    .section {
        padding: var(--section-padding-mobile);
    }
}

/* ===================================
   Buttons
   =================================== */
.btn {
    display: inline-block;
    padding: 12px 30px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-white);
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.btn-secondary:hover {
    background: var(--color-primary);
    color: var(--color-white);
}

/* ===================================
   MOBILE MENU - SUBMENU TOGGLE BUTTONS
   FIXED: Perfect alignment WITHOUT moving when submenu opens
   =================================== */

.mobile-nav-menu .menu-item-has-children {
    position: relative;
}

/* Parent link styling - consistent padding and height */
.mobile-nav-menu .menu-item-has-children > a {
    padding: 16px 75px 16px 20px !important;
    display: flex;
    align-items: center;
    min-height: 60px;
    line-height: 1.4;
}

/* Submenu Toggle Button - anchored to TOP, not center */
.submenu-toggle {
    position: absolute;
    right: 8px;
    top: 8px; /* Fixed top position - won't recalculate */
    width: 44px;
    height: 44px;
    background: rgba(220, 20, 60, 0.1);
    border: 2px solid rgba(220, 20, 60, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
    z-index: 10;
    outline: none;
    flex-shrink: 0;
}

.submenu-toggle:hover {
    background: rgba(220, 20, 60, 0.2);
    border-color: rgba(220, 20, 60, 0.4);
    transform: scale(1.05);
}

.submenu-toggle:active {
    transform: scale(0.95);
}

/* Icon inside toggle button */
.submenu-toggle i {
    color: #DC143C;
    font-size: 14px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center center;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Active state - button pressed */
.submenu-toggle.active {
    background: rgba(220, 20, 60, 0.15);
    border-color: #DC143C;
}

.submenu-toggle.active i {
    color: #DC143C;
    transform: rotate(180deg);
}

/* Focus state for accessibility */
.submenu-toggle:focus {
    outline: 2px solid #DC143C;
    outline-offset: 2px;
    border-color: #DC143C;
}

/* Submenu styles */
.mobile-nav-menu .sub-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    margin-top: 8px;
}

.mobile-nav-menu .menu-item-has-children.active > .sub-menu {
    padding: 8px 0;
}

/* Submenu items */
.mobile-nav-menu .sub-menu li {
    opacity: 1;
}

.mobile-nav-menu .sub-menu a {
    padding: 12px 20px 12px 40px !important;
    font-size: 0.95rem;
    position: relative;
}

.mobile-nav-menu .sub-menu a::before {
    content: '→';
    position: absolute;
    left: 20px;
    color: #DC143C;
    opacity: 0;
    transition: all 0.3s ease;
}

.mobile-nav-menu .sub-menu a:hover::before {
    opacity: 1;
    left: 18px;
}

/* Nested submenus */
.mobile-nav-menu .sub-menu .menu-item-has-children .submenu-toggle {
    width: 36px;
    height: 36px;
    top: 6px;
}

.mobile-nav-menu .sub-menu .menu-item-has-children > a {
    padding-right: 50px !important;
}

/* Visual feedback for clickable parent links */
.mobile-nav-menu .menu-item-has-children > a.has-submenu {
    cursor: pointer;
    position: relative;
}

.mobile-nav-menu .menu-item-has-children > a.has-submenu::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 60px;
    height: 2px;
    background: linear-gradient(90deg, #DC143C, transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-nav-menu .menu-item-has-children > a.has-submenu:hover::after {
    opacity: 0.3;
}

/* Improved touch targets for mobile */
@media (max-width: 768px) {
    .submenu-toggle {
        width: 48px;
        height: 48px;
        right: 4px;
        top: 8px;
    }
    
    .mobile-nav-menu .menu-item-has-children > a {
        padding: 18px 65px 18px 20px !important;
        min-height: 64px;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .submenu-toggle {
        width: 42px;
        height: 42px;
        top: 9px;
    }
    
    .mobile-nav-menu .menu-item-has-children > a {
        padding: 16px 55px 16px 20px !important;
    }
}

/* ===================================
   Footer Styles - FIXED SPACING & CONTRAST
   =================================== */
.site-footer {
    background: #1A1D23;
    color: #C5C9D0; /* IMPROVED: was #B8BCC8 - now 5.92:1 contrast */
    margin-top: 0; /* REMOVED: was 80px - eliminates whitespace gap */
    position: relative;
    overflow: hidden;
}

/* Decorative top border */
.site-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, 
        transparent, 
        #DC143C 20%, 
        #DC143C 80%, 
        transparent
    );
}

/* Main Footer Area */
.footer-main {
    padding: 80px 0 40px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Footer Grid Layout */
.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1.2fr;
    gap: 40px;
}

/* Footer Columns */
.footer-column {
    padding: 0;
}

.footer-about {
    padding-right: 20px;
}

/* ===================================
   Footer Logo & About
   =================================== */
.footer-logo {
    margin-bottom: 20px;
}

.footer-logo-img {
    height: 50px;
    width: auto;
    filter: brightness(0) invert(1);
    transition: opacity 0.3s ease;
}

.footer-logo-img:hover {
    opacity: 0.8;
}

.footer-logo-text {
    color: #FFFFFF;
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 20px;
    letter-spacing: -0.5px;
}

.footer-description {
    color: #C2C6CD; /* IMPROVED: was #9CA3AF - now 5.62:1 contrast */
    line-height: 1.8;
    margin-bottom: 25px;
    font-size: 0.95rem;
}

/* ===================================
   Social Links
   =================================== */
.footer-social {
    display: flex;
    gap: 12px;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: #C5C9D0; /* IMPROVED: was #B8BCC8 - now 5.92:1 contrast */
    transition: all 0.3s ease;
}

.social-link:hover {
    background: #DC143C;
    border-color: #DC143C;
    color: #FFFFFF;
    transform: translateY(-2px);
}

.social-link i {
    font-size: 16px;
}

/* ===================================
   Footer Headings
   =================================== */
.footer-title {
    color: #FFFFFF;
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 20px;
    position: relative;
    padding-bottom: 10px;
}

.footer-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 30px;
    height: 2px;
    background: #DC143C;
}

/* ===================================
   Footer Menus
   =================================== */
.footer-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-menu li {
    margin-bottom: 12px;
}

.footer-menu a {
    color: #C2C6CD; /* IMPROVED: was #9CA3AF - now 5.62:1 contrast */
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    display: inline-block;
    position: relative;
}

.footer-menu a:hover {
    color: #FFFFFF;
    transform: translateX(5px);
}

.footer-menu a::before {
    content: '';
    position: absolute;
    left: -15px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 1px;
    background: #DC143C;
    transition: width 0.3s ease;
}

.footer-menu a:hover::before {
    width: 8px;
}

/* ===================================
   Footer Contact
   =================================== */
.footer-contact {
    list-style: none;
    margin: 0 0 30px;
    padding: 0;
}

.footer-contact li {
    display: flex;
    align-items: flex-start;
    margin-bottom: 16px;
    color: #C2C6CD; /* IMPROVED: was #9CA3AF - now 5.62:1 contrast */
    font-size: 0.95rem;
}

.footer-contact i {
    color: #DC143C;
    margin-right: 12px;
    margin-top: 3px;
    width: 16px;
    text-align: center;
}

.footer-contact a {
    color: #C2C6CD; /* IMPROVED: was #9CA3AF - now 5.62:1 contrast */
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-contact a:hover {
    color: #FFFFFF;
}


/* ===================================
   Footer Bottom - CRITICAL CONTRAST FIX
   =================================== */
.footer-bottom {
    background: #0F1419;
    padding: 25px 0;
}

.footer-bottom-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.copyright p {
    margin: 0;
    color: #A8ADB5; /* CRITICAL FIX: was #6B7280 - now 5.70:1 contrast */
    font-size: 0.875rem;
}

.footer-bottom-menu ul {
    display: flex;
    gap: 30px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-bottom-menu a {
    color: #A8ADB5; /* CRITICAL FIX: was #6B7280 - now 5.70:1 contrast */
    font-size: 0.875rem;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-bottom-menu a:hover {
    color: #FFFFFF;
}

/* ===================================
   Back to Top Button
   =================================== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    background: #DC143C;
    color: #FFFFFF;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: var(--z-index-fixed);
    box-shadow: 0 4px 15px rgba(220, 20, 60, 0.3);
}

.back-to-top:hover {
    background: #B91C3C;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(220, 20, 60, 0.4);
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top i {
    font-size: 18px;
}

/* ===================================
   Forms
   =================================== */
input,
textarea,
select {
    width: 100%;
    padding: 12px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-primary);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* ===================================
   Responsive Design
   =================================== */
/* Tablet - 991px */
@media (max-width: 991px) {
    .footer-main {
        padding: 60px 0 30px;
    }
    
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 40px 30px;
    }
    
    .footer-about {
        grid-column: 1 / -1;
        padding-right: 0;
        text-align: center;
    }
    
    .footer-logo {
        display: flex;
        justify-content: center;
    }
    
    .footer-social {
        justify-content: center;
    }
    
    .footer-bottom-content {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
}

/* Mobile - 768px */
@media (max-width: 768px) {
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }
    h3 { font-size: 1.75rem; }
    
    .container {
        padding: 0 15px;
    }
    
    .site-footer {
        margin-top: 0; /* REMOVED: was 60px - no whitespace on mobile */
    }
    
    .footer-main {
        padding: 50px 0 30px;
    }
    
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 35px;
    }
    
    .footer-column {
        text-align: center;
    }
    
    .footer-title::after {
        left: 50%;
        transform: translateX(-50%);
    }
    
    .footer-menu a::before {
        display: none;
    }
    
    .footer-contact {
        max-width: 300px;
        margin: 0 auto 30px;
        text-align: left;
    }
    
    .footer-newsletter {
        max-width: 300px;
        margin: 30px auto 0;
    }
    
    .back-to-top {
        right: 20px;
        bottom: 20px;
        width: 40px;
        height: 40px;
    }
    
    .back-to-top i {
        font-size: 16px;
    }
}

/* Small Mobile - 480px */
@media (max-width: 480px) {
    .footer-bottom-menu ul {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    .copyright p {
        font-size: 0.8rem;
        line-height: 1.5;
    }
}

/* ===================================
   Utilities
   =================================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mt-5 { margin-top: 3rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mb-5 { margin-bottom: 3rem; }

.grid {
    display: grid;
    gap: 2rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Screen Reader Text */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal;
}

/* ===================================
   Components
   =================================== */
/* Cards */
.card {
    background: var(--color-white);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

/* Section Headers */
.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.section-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Feature Lists */
.feature-list {
    list-style: none;
    padding: 0;
}

.feature-list li {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.feature-list i {
    color: var(--color-primary);
    margin-right: 1rem;
    font-size: 1.25rem;
}

/* ===================================
   Animations
   =================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.fade-in {
    animation: fadeIn 0.6s ease-out;
}

/* Animate footer elements on scroll */
.footer-column {
    animation: fadeInUp 0.6s ease backwards;
}

.footer-column:nth-child(1) {
    animation-delay: 0.1s;
}

.footer-column:nth-child(2) {
    animation-delay: 0.2s;
}

.footer-column:nth-child(3) {
    animation-delay: 0.3s;
}

.footer-column:nth-child(4) {
    animation-delay: 0.4s;
}

/* Loading States */
.loading {
    position: relative;
    color: transparent;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--color-primary);
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

/* ===================================
   Dark Mode Support
   =================================== */
@media (prefers-color-scheme: dark) {
    body {
        background: var(--color-dark-bg);
        color: var(--text-on-dark);
    }
    
    .footer-logo-img {
        filter: none;
    }
}

/* ===================================
   Print Styles
   =================================== */
@media print {
    .site-footer {
        background: none;
        color: #000;
    }
    
    .back-to-top,
    .footer-social,
    .footer-newsletter {
        display: none;
    }
}

/* ===================================
   Accessibility
   =================================== */
.footer-menu a:focus,
.footer-contact a:focus,
.social-link:focus,
.btn-subscribe:focus,
.back-to-top:focus {
    outline: 2px solid #DC143C;
    outline-offset: 2px;
}

/* Skip link for keyboard navigation */
.footer-menu a:focus {
    color: #FFFFFF;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .site-footer {
        border-top: 2px solid #FFFFFF;
    }
    
    .footer-title::after {
        height: 3px;
    }
    
    .social-link {
        border-width: 2px;
    }
}