/* ==========================================================================
   WritePrompt - Main Styles
   Mobile-first responsive design
   ========================================================================== */

/* CSS Variables */
:root {
    /* Colors */
    --primary: #2c3e50;
    --secondary: #27ae60;
    --accent: #3498db;
    --purple: #9b59b6;
    --orange: #e67e22;
    --danger: #e74c3c;
    --success: #27ae60;
    --warning: #f39c12;
    --info: #3498db;
    
    /* Backgrounds */
    --background: #ffffff;
    --background-alt: #f8f9fa;
    --surface: #ffffff;
    --light: #ecf0f1;
    --dark: #34495e;
    
    /* Borders */
    --border: #dee2e6;
    --border-light: #e9ecef;
    --border-dark: #adb5bd;
    
    /* Text Colors */
    --text: #212529;
    --text-light: #495057;
    --text-muted: #6c757d;
    --text-inverse: #ffffff;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-xxl: 3rem;
    
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-serif: Georgia, 'Times New Roman', serif;
    --font-mono: 'Courier New', Courier, monospace;
    
    /* Borders */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.15);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
    
    /* Z-index layers */
    --z-base: 1;
    --z-dropdown: 10;
    --z-sticky: 100;
    --z-fixed: 200;
    --z-modal-backdrop: 300;
    --z-modal: 400;
    --z-popover: 500;
    --z-tooltip: 600;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --primary: #3498db;
        --secondary: #2ecc71;
        --text: #ecf0f1;
        --text-light: #bdc3c7;
        --text-muted: #95a5a6;
        --background: #1a1a1a;
        --background-alt: #2c2c2c;
        --surface: #34495e;
        --light: #34495e;
        --border: #4a5568;
        --border-light: #4a5568;
        --border-dark: #2d3748;
    }
}

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

/* Ensure consistent rendering across browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, main, nav, section {
    display: block;
}

/* Remove default button styling */
button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    outline: inherit;
}

/* Remove default list styling */
ul, ol {
    list-style: none;
}

/* Improve image rendering */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Improve table rendering */
table {
    border-collapse: collapse;
    border-spacing: 0;
}

html {
    font-size: 18px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--text);
    background: var(--background-alt);
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    color: var(--primary);
    margin-bottom: var(--space-md);
}

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

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

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-base);
}

a:hover {
    color: var(--secondary);
}

a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Container */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

@media (min-width: 768px) {
    .container {
        padding: 0 var(--space-xl);
    }
}

/* Header */
.main-header {
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    border-bottom: 1px solid var(--border-light);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    max-width: 1400px;
    margin: 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
}

.logo a {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: inherit;
}

.logo-text {
    display: none;
}

@media (min-width: 480px) {
    .logo-text {
        display: inline;
    }
}

.desktop-nav {
    display: none;
    gap: var(--space-lg);
}

.desktop-nav a {
    color: var(--text);
    font-weight: 500;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
}

.desktop-nav a:hover,
.desktop-nav a.active {
    background: var(--light);
    color: var(--primary);
}

@media (min-width: 768px) {
    .desktop-nav {
        display: flex;
    }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Hamburger Menu */
.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 28px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 10;
}

.hamburger span {
    width: 100%;
    height: 3px;
    background: var(--primary);
    border-radius: 10px;
    transition: all var(--transition-base);
}

.hamburger:hover span {
    background: var(--secondary);
}

@media (min-width: 768px) {
    .hamburger {
        display: none;
    }
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    font-weight: 500;
    font-family: inherit;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

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

.btn-primary:hover {
    background: #219a52;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

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

.btn-secondary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.btn-outline:hover {
    border-color: var(--primary);
    background: var(--light);
    color: var(--primary);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.25rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 1rem;
}

.btn-full {
    width: 100%;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn:disabled:hover,
.btn[disabled]:hover {
    transform: none;
    box-shadow: none;
}

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

.btn-ghost:hover {
    background: var(--light);
    color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: var(--text-inverse);
}

.btn-danger:hover {
    background: #c0392b;
    color: var(--text-inverse);
}

.btn-warning {
    background: var(--warning);
    color: var(--text-inverse);
}

.btn-warning:hover {
    background: #e67e22;
    color: var(--text-inverse);
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all var(--transition-base);
}

.icon-btn:hover {
    background: var(--light);
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    border: 1px solid var(--border-light);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.card-action {
    background: var(--light);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--transition-base);
}

.card-action:hover {
    background: var(--secondary);
    color: white;
}

/* Tags */
.tag {
    display: inline-block;
    background: #d5dce0;
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    color: #2c3e50;
    border: 1px solid #adb5bd;
    white-space: nowrap;
    font-weight: 600;
}

.tag-primary {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

.tag-secondary {
    background: var(--secondary);
    color: var(--text-inverse);
    border-color: var(--secondary);
}

.tag-accent {
    background: var(--accent);
    color: var(--text-inverse);
    border-color: var(--accent);
}

/* Section Titles */
.section-title {
    text-align: center;
    font-size: clamp(2rem, 4vw, 2.5rem);
    margin-bottom: var(--space-xxl);
    color: var(--primary);
}

/* Footer */
.main-footer {
    background: var(--primary);
    color: white;
    padding: var(--space-xl) var(--space-md);
    text-align: center;
    margin-top: var(--space-xxl);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-xl);
    max-width: 1200px;
    margin: 0 auto;
    text-align: left;
    margin-bottom: var(--space-xl);
}

@media (min-width: 640px) {
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .footer-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.footer-section h3,
.footer-section h4 {
    color: white;
    margin-bottom: var(--space-md);
}

.footer-section p {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: var(--space-md);
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: var(--space-sm);
}

.footer-section a {
    color: rgba(255, 255, 255, 0.8);
    transition: color var(--transition-base);
}

.footer-section a:hover {
    color: white;
}

.footer-social {
    display: flex;
    gap: var(--space-md);
    font-size: 1.5rem;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: var(--space-lg);
    margin-top: var(--space-lg);
}

.footer-bottom p {
    margin: var(--space-sm) 0;
    color: rgba(255, 255, 255, 0.7);
}

.footer-bottom a {
    color: rgba(255, 255, 255, 0.9) !important;
    text-decoration: none;
    transition: color var(--transition-base);
}

.footer-bottom a:hover {
    color: white !important;
    text-decoration: underline;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

.modal-large {
    max-width: 800px;
}

@media (max-width: 768px) {
    .modal-large {
        max-width: 95vw;
    }
    
    .modal-content {
        max-width: 95vw;
        max-height: 95vh;
    }
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.modal-header h3 {
    margin: 0;
    color: var(--primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
}

.modal-close:hover {
    background: var(--light);
    color: var(--text);
}

.modal-body {
    padding: var(--space-lg);
    background: var(--surface);
}

/* Alerts & Notifications */
.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    border: 1px solid transparent;
    font-weight: 500;
}

.alert-info {
    background: #e3f2fd;
    color: #0d47a1;
    border-color: #bbdefb;
}

.alert-success {
    background: #e8f5e8;
    color: #1b5e20;
    border-color: #c8e6c9;
}

.alert-warning {
    background: #fff3e0;
    color: #e65100;
    border-color: #ffcc02;
}

.alert-danger {
    background: #ffebee;
    color: #b71c1c;
    border-color: #ffcdd2;
}

.alert-dismissible {
    position: relative;
    padding-right: 3rem;
}

.alert-close {
    position: absolute;
    top: 0;
    right: 0;
    padding: var(--space-md);
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

.alert-close:hover {
    opacity: 1;
}

/* Forms */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 600;
    color: var(--primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    font-family: inherit;
    transition: border-color var(--transition-base);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--secondary);
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.form-group .form-help {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.form-group.error input,
.form-group.error textarea,
.form-group.error select {
    border-color: var(--danger);
}

.form-group.error .form-help {
    color: var(--danger);
}

.form-group.success input,
.form-group.success textarea,
.form-group.success select {
    border-color: var(--success);
}

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

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mt-4 { margin-top: var(--space-xl); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }
.mb-4 { margin-bottom: var(--space-xl); }

.hidden { display: none; }
.visible { display: block; }

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease;
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Loading states */
.loading {
    position: relative;
    pointer-events: none;
}

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

.btn.loading {
    color: transparent;
}

.btn.loading::after {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: white;
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary);
    color: var(--text-inverse);
    padding: 8px;
    text-decoration: none;
    border-radius: var(--radius-sm);
    z-index: 1000;
}

.skip-link:focus {
    top: 6px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border: #000000;
        --border-light: #000000;
        --text-light: #000000;
        --text-muted: #333333;
    }
    
    .btn-outline {
        border-width: 3px;
    }
    
    .card,
    .prompt-card,
    .feature-card {
        border: 2px solid var(--border);
    }
}

/* Focus visible (keyboard navigation) */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Improved focus for interactive elements */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Focus trap for modals */
.modal.active {
    isolation: isolate;
}

/* Ensure focus is visible in high contrast mode */
@media (prefers-contrast: high) {
    *:focus-visible {
        outline: 3px solid var(--accent);
        outline-offset: 3px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Lists */
.list-unstyled {
    list-style: none;
    padding-left: 0;
}

.list-inline {
    list-style: none;
    padding-left: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--space-lg);
}

.table th,
.table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    color: var(--primary);
    background: var(--light);
}

.table-striped tbody tr:nth-child(odd) {
    background: var(--background-alt);
}

.table-hover tbody tr:hover {
    background: var(--light);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: var(--radius-sm);
    background: var(--text-muted);
    color: var(--text-inverse);
}

.badge-primary {
    background: var(--primary);
}

.badge-secondary {
    background: var(--secondary);
}

.badge-success {
    background: var(--success);
}

.badge-danger {
    background: var(--danger);
}

.badge-warning {
    background: var(--warning);
}

.badge-info {
    background: var(--info);
}

/* Print styles */
@media print {
    .main-header,
    .main-footer,
    .hamburger,
    .fab,
    .btn {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid var(--border);
    }
}

