/*
 * Style Sheet for Pwacom PWA Frontend
 *
 * This CSS file provides base styles for the Progressive Web App frontend,
 * ensuring a consistent and responsive user experience across devices.
 *
 * @version 2.0.0
 * @author Pwacom Team
 */

/* --- 1. CSS Variables for Theme Management --- */
:root {
    /* Primary Colors */
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --primary-light: #5dade2;

    /* Secondary Colors */
    --secondary-color: #2ecc71;
    --secondary-dark: #27ae60;

    /* Neutral Colors */
    --text-color: #2c3e50;
    --text-light: #7f8c8d;
    --bg-color: #f8f9fa;
    --bg-dark: #34495e;
    --white: #ffffff;
    --border-color: #ecf0f1;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Border Radius */
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* --- 2. CSS Reset & Base Styles --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue',
                 Arial, 'Noto Sans', 'Noto Sans Arabic', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Focus styles for accessibility */
:focus {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --- 3. Typography --- */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Georgia', serif, 'Noto Serif Arabic', serif;
    margin-bottom: var(--spacing-sm);
    color: var(--text-color);
    line-height: 1.2;
    font-weight: 600;
}

h1 { font-size: clamp(2rem, 5vw, 2.5rem); }
h2 { font-size: clamp(1.75rem, 4vw, 2rem); }
h3 { font-size: clamp(1.5rem, 3.5vw, 1.75rem); }
h4 { font-size: clamp(1.25rem, 3vw, 1.5rem); }
h5 { font-size: clamp(1.1rem, 2.5vw, 1.25rem); }
h6 { font-size: clamp(1rem, 2vw, 1.1rem); }

p {
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover,
a:focus {
    color: var(--primary-dark);
    text-decoration: underline;
}

ul, ol {
    margin-bottom: var(--spacing-md);
    padding-left: var(--spacing-lg);
}

li {
    margin-bottom: var(--spacing-xs);
}

/* --- 4. General Layout --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-md);
    width: 100%;
}

header {
    background-color: var(--bg-dark);
    color: var(--white);
    padding: var(--spacing-md) 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
}

header .site-title {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin: 0;
    text-align: center;
}

nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) 0 0 0;
}

nav ul li {
    margin: 0;
}

nav ul li a {
    color: var(--white);
    font-weight: 500;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    transition: background-color var(--transition-fast);
}

nav ul li a:hover,
nav ul li a:focus {
    background-color: rgba(255, 255, 255, 0.1);
    text-decoration: none;
}

.main-content {
    padding: var(--spacing-xl) 0;
    min-height: calc(100vh - 120px);
}

footer {
    background-color: var(--bg-dark);
    color: var(--white);
    padding: var(--spacing-lg) 0;
    text-align: center;
}

/* --- 5. Form Elements --- */
button,
input[type="submit"],
input[type="button"],
.button {
    background-color: var(--secondary-color);
    color: var(--white);
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    min-height: 44px; /* Minimum touch target size */
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
.button:hover,
button:focus,
input[type="submit"]:focus,
input[type="button"]:focus,
.button:focus {
    background-color: var(--secondary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

button:active,
input[type="submit"]:active,
input[type="button"]:active,
.button:active {
    transform: translateY(0);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    min-height: 44px; /* Minimum touch target size */
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    outline: none;
}

/* --- 6. Utility Classes --- */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

.mb-10 { margin-bottom: var(--spacing-md); }
.mb-20 { margin-bottom: var(--spacing-lg); }
.mt-10 { margin-top: var(--spacing-md); }
.mt-20 { margin-top: var(--spacing-lg); }
.p-20 { padding: var(--spacing-lg); }

.flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-10 { gap: var(--spacing-md); }
.gap-20 { gap: var(--spacing-lg); }

.card {
    background-color: var(--white);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

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

/* --- 7. PWA Specific Styles --- */
.pwa-install-button {
    background-color: var(--primary-color);
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: 1001;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    box-shadow: var(--shadow-lg);
}

.pwa-install-button:hover {
    background-color: var(--primary-dark);
    transform: scale(1.05);
}

.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: #e74c3c;
    color: white;
    padding: var(--spacing-sm);
    text-align: center;
    z-index: 1002;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.loading-indicator {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--white);
    animation: spin 1s ease-in-out infinite;
}

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

/* --- 8. Responsive Design --- */
@media (max-width: 768px) {
    :root {
        font-size: 15px;
    }

    .container {
        padding: var(--spacing-sm);
    }

    nav ul {
        flex-direction: column;
        gap: var(--spacing-xs);
    }

    nav ul li a {
        display: block;
        text-align: center;
        padding: var(--spacing-sm);
    }

    .pwa-install-button {
        bottom: var(--spacing-md);
        right: var(--spacing-md);
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 480px) {
    :root {
        font-size: 14px;
    }

    .container {
        padding: var(--spacing-xs);
    }

    .main-content {
        padding: var(--spacing-md) 0;
    }
}

/* --- 9. RTL Support --- */
[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] ul,
[dir="rtl"] ol {
    padding-left: 0;
    padding-right: var(--spacing-lg);
}

[dir="rtl"] .text-left { text-align: right; }
[dir="rtl"] .text-right { text-align: left; }

/* --- 10. Dark Mode Support --- */
@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #ecf0f1;
        --text-light: #bdc3c7;
        --bg-color: #2c3e50;
        --bg-dark: #1a2530;
        --border-color: #34495e;
    }

    .card {
        background-color: var(--bg-dark);
    }
}

/* --- 11. Print Styles --- */
@media print {
    * {
        background: transparent !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    body {
        font-size: 12pt;
        line-height: 1.5;
    }

    nav,
    .pwa-install-button,
    .offline-indicator {
        display: none !important;
    }

    a[href]::after {
        content: " (" attr(href) ")";
    }

    abbr[title]::after {
        content: " (" attr(title) ")";
    }
}
