/* =====================================================
   MASTER COLOR SYSTEM - WCAG AA COMPLIANT
   ===================================================== */

:root {
    /* Primary Brand Color */
    --primary-brand: #0052CC;           /* Royal Blue */
    --primary-dark: #003A99;            /* Darker variant for states */
    --primary-light: #0066FF;           /* Lighter variant for hover */
    
    /* Secondary/Accent Color */
    --secondary-accent: #F4F5F7;        /* Light Grey */
    --secondary-dark: #636E72;          /* Steel Grey */
    
    /* Text Colors - High Contrast */
    --text-primary: #172B4D;            /* Dark Navy - 4.5:1+ contrast on white */
    --text-secondary: #44546F;          /* Medium Grey */
    --text-light: #FFFFFF;              /* White text on dark */
    
    /* Background Colors */
    --bg-light: #FFFFFF;
    --bg-dark: #121212;
    --bg-surface: #F9FAFB;
    
    /* Status Colors - High Contrast */
    --success: #1B8917;                 /* Dark Green */
    --error: #AE0A07;                   /* Dark Red */
    --warning: #A85C00;                 /* Dark Orange */
    --info: #003A8C;                    /* Dark Blue */
    
    /* Surface & Dividers */
    --border-color: #D0D7DE;
    --divider: #E1E4E8;
}

/* Dark Mode Overrides */
body.dark-mode {
    --bg-light: #1F2937;
    --bg-dark: #111827;
    --bg-surface: #374151;
    --text-primary: #F3F4F6;
    --text-secondary: #D1D5DB;
    --border-color: #4B5563;
}

/* =====================================================
   Enhanced Mobile & RTL Support Stylesheet
   ===================================================== */

/* RTL (Right-to-Left) Support for Arabic */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .sidebar-item {
    transform: translateX(-4px);
}

[dir="rtl"] .sidebar-item:hover {
    transform: translateX(-4px);
}

[dir="rtl"] .calculator-item:hover {
    transform: translateX(-8px);
}

[dir="rtl"] .alert {
    border-left: none;
    border-right: 4px solid #3b82f6;
    padding-left: 1rem;
    padding-right: 0;
}

[dir="rtl"] .badge {
    margin-right: 0;
    margin-left: 0.5rem;
}

/* Mobile Optimization */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        display: flex;
        overflow-x: auto;
        padding: 0.5rem 0;
        border-bottom: 1px solid rgba(255,255,255,0.2);
        border-right: none;
    }

    .module-group {
        display: inline-block;
        min-width: fit-content;
        margin-right: 2rem;
        padding: 0 1rem;
    }

    [dir="rtl"] .module-group {
        margin-right: 0;
        margin-left: 2rem;
    }

    .module-header {
        font-size: 0.85rem;
        whitespace: nowrap;
    }

    .calculator-list {
        display: flex;
        gap: 0.5rem;
        flex-direction: row;
    }

    .sidebar-item {
        min-width: 150px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (max-width: 768px) {
    html, body {
        font-size: 14px;
    }

    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: static;
        padding: 0.5rem;
        display: flex;
        flex-wrap: wrap;
    }

    .main-content {
        width: 100%;
    }

    .navbar {
        flex-wrap: wrap;
        gap: 1rem;
        padding: 1rem;
    }

    .navbar h1 {
        font-size: 1.2rem;
        flex: 1;
    }

    .navbar div {
        width: 100%;
        display: flex;
        gap: 0.5rem;
        justify-content: space-between;
    }

    .navbar button {
        flex: 1;
        padding: 0.5rem !important;
        font-size: 0.85rem;
    }

    .app-content {
        padding: 1rem 0.5rem;
    }

    .cards-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .card {
        padding: 1.5rem 1rem;
    }

    .card-icon {
        font-size: 2.5rem;
    }

    .dashboard-header h1 {
        font-size: 2rem;
    }

    .dashboard-header p {
        font-size: 1rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .input, .select-input {
        padding: 0.65rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .btn {
        padding: 0.65rem 1.25rem;
        font-size: 0.95rem;
        width: 100%;
    }

    .notification {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        font-size: 0.85rem;
    }

    .calculator-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .module-group {
        width: 100%;
        margin-right: 0;
        margin-bottom: 1rem;
    }

    .module-header {
        font-size: 0.9rem;
    }

    .calculator-list {
        width: 100%;
        flex-direction: column;
    }

    .sidebar-item {
        width: 100%;
        padding: 0.65rem 0.75rem;
        font-size: 0.85rem;
    }

    .text-muted {
        font-size: 0.85rem;
    }

    .alert {
        padding: 0.75rem;
        font-size: 0.85rem;
    }

    .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
}

@media (max-width: 480px) {
    html, body {
        font-size: 13px;
    }

    .navbar {
        padding: 0.75rem 0.5rem;
    }

    .navbar h1 {
        font-size: 1rem;
    }

    .navbar div {
        width: 100%;
        gap: 0.25rem;
    }

    .navbar button, .navbar select {
        font-size: 0.75rem;
        padding: 0.4rem !important;
    }

    .app-content {
        padding: 0.75rem 0.25rem;
    }

    .card {
        padding: 1rem 0.75rem;
    }

    .card-icon {
        font-size: 2rem;
    }

    .card h3 {
        font-size: 1rem;
    }

    .card p {
        font-size: 0.8rem;
    }

    .dashboard-header h1 {
        font-size: 1.5rem;
    }

    .dashboard-header p {
        font-size: 0.9rem;
    }

    .form-label {
        font-size: 0.85rem;
    }

    .input, .select-input {
        padding: 0.6rem;
        font-size: 14px;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    .workspace-header h2 {
        font-size: 1.5rem;
    }

    .sidebar-item {
        padding: 0.5rem 0.5rem;
        font-size: 0.8rem;
    }

    .form-group {
        margin-bottom: 0.75rem;
    }

    [dir="rtl"] .module-group {
        margin-left: 0;
    }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
    .btn, .sidebar-item, .calculator-item, .card {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .btn:active {
        opacity: 0.8;
        transform: scale(0.98);
    }

    .sidebar-item:active {
        opacity: 0.8;
    }
}

/* Responsive table styles */
@media (max-width: 768px) {
    table {
        font-size: 0.85rem;
    }

    th, td {
        padding: 0.5rem;
    }
}

/* Flexbox utilities for responsive layout */
.flex-col {
    display: flex;
    flex-direction: column;
}

.flex-row {
    display: flex;
    flex-direction: row;
}

@media (max-width: 768px) {
    .flex-col-mobile {
        flex-direction: column;
    }

    .flex-row-mobile {
        flex-direction: row;
    }
}

/* Print styles */
@media print {
    .navbar, .sidebar, .btn, .notification {
        display: none;
    }

    .container {
        background: white;
    }

    .app-content {
        padding: 0;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: more) {
    .glass {
        border-width: 2px;
    }

    .card {
        border-width: 2px;
    }

    .btn-primary {
        text-decoration: underline;
    }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    body {
        background: #0f172a;
    }

    body.dark-mode {
        background: #0f172a;
    }
}

/* Language selector styling */
#language-selector {
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

#language-selector:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

#language-selector:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

#language-selector option {
    background: #374151;
    color: white;
}

@media (max-width: 768px) {
    #language-selector {
        padding: 0.4rem 0.5rem;
        font-size: 0.8rem;
        flex: 1;
    }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(16, 185, 129, 0.3);
    border-radius: 50%;
    border-top-color: #10b981;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Sticky header */
.sticky-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: inherit;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Selection styling */
::selection {
    background: rgba(16, 185, 129, 0.3);
    color: inherit;
}

body.dark-mode ::selection {
    background: rgba(16, 185, 129, 0.5);
}
