/**
 * Shared CSS Core Styles
 * 
 * This file provides foundational styles and common components used throughout the application.
 * It implements the design system defined in variables.css and creates reusable patterns.
 * 
 * Table of Contents:
 * 1. Imports & CSS Reset
 * 2. Root & Base Styles
 * 3. Typography System
 * 4. Layout Components
 * 5. Navigation Elements
 * 6. Header Components
 * 7. Interactive Elements
 * 8. Grid Systems
 * 9. Utility Classes
 * 10. Responsive Design
 * 11. Accessibility Features
 * 12. Animation Components
 */

/* Import base styles and animations */
@import 'variables.css';
@import 'animations.css';

/* CSS Reset and Box Model Fix
 * Ensures consistent box-sizing and removes default margins/padding
 */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Root Variables
 * Modern viewport units and theme colors
 * --vh/--vw: Viewport units for mobile compatibility
 * Colors follow a dark theme with orange accent
 */
:root {
    --vh: 1vh;
    --vw: 1vw;
    --primary-color: #ff8c00;
    --primary-hover: #e07b00;
    --bg-dark: #121212;
    --bg-darker: #1a1a1a;
    --bg-light: #2a2a2a;
    --bg-header: #232323;
    --text-light: #f1f1f1;
    --text-gray: #ccc;
    --border-radius: 8px;
    --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    --header-height: 60px;
    --footer-height: 60px;
}

/* Base HTML Elements
 * Sets up foundational styles for html/body
 * Uses logical properties for better internationalization
 */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: #1a1a1a;
    color: #f1f1f1;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    padding-top: var(--header-height);
    position: relative;
}

html {
    height: auto;
    overflow-y: visible;
}

/* Modern Header Component
 * Fixed position header with backdrop filter
 * Provides consistent navigation structure
 */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--color-surface);
    border-bottom: 3px solid var(--color-primary);
    z-index: 997; /* Reduced to be below hamburger */
    display: flex;
    align-items: center;
    padding: 0 var(--space-md);
    justify-content: center; /* Center the title */
}

.header-link {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.header-link:hover {
    opacity: 0.8;
}

header h1 {
    margin: 0;
    padding: 0;
    color: var(--primary-color);
    font-size: clamp(1.2rem, 4vw, 2.5rem);
    text-transform: uppercase;
    letter-spacing: clamp(1px, 0.5vw, 2px);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

/* Modern button styles with logical properties */
.button, 
.admin-link {
    background-color: var(--color-primary);
    padding-block: var(--space-sm);
    padding-inline: var(--space-md);
    border-radius: var(--border-radius);
    border: none;
    color: #000;
    font-weight: bold;
    text-decoration: none;
    transition: transform var(--transition-base),
                background-color var(--transition-base);
    position: relative;
    overflow: hidden;
}

.button:hover,
.admin-link:hover {
    background-color: var(--color-primary-hover);
    transform: translateY(-2px);
}

.button:active,
.admin-link:active {
    transform: translateY(1px);
}

/* Consistent button styles */
.btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all var(--transition-base) var(--transition-bezier);
    background: var(--gradient-primary);
    background-size: 200% auto;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    background-position: right center;
    transform: translateY(-2px);
    box-shadow: var(--shadow-primary);
}

/* Container with modern grid system */
.container {
    width: clamp(300px, 95%, 1200px);
    margin-inline: auto;
    padding: clamp(10px, 3vw, 20px);
    padding-block-start: max(80px, 12vh);
    display: grid;
    gap: var(--space-md);
    background-color: var(--bg-darker);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    flex: 1;
    opacity: 0;
    animation: fadeIn 0.4s ease-out forwards;
    transition: none;
}

/* Consistent card styles */
.card {
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    padding: var(--space-md);
    border-left: 5px solid var(--color-primary);
    transition: all var(--transition-base) var(--transition-bezier);
}

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

/* Add new shared components */
.entry-actions {
    display: flex;
    gap: 10px;
    margin: 1rem 0;
}

.action-btn {
    padding: 8px 16px;
    border-radius: var(--border-radius);
    color: white;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s ease;
}

.type-badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 500;
    margin-right: 10px;
}

/* Unified section headers */
h2 {
    color: var(--primary-color);
    font-size: 24px;
    padding-bottom: 10px;
    border-bottom: 3px solid var(--primary-color);
    margin-bottom: 30px;
}

/* Unified footer */
footer {
    background-color: var(--bg-header);
    padding: 1rem;
    text-align: center;
    color: var(--text-light);
    width: 100%;
    margin-top: auto;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        width: 100%;
        padding: 10px;
        padding-block-start: max(60px, 8vh);
    }

    .header {
        height: clamp(50px, 6vh, 60px);
        padding: var(--space-sm);
    }

    header h1 {
        font-size: 1.5rem;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }

    .button, 
    .admin-link {
        width: 100%;
        text-align: center;
        margin: 5px 0;
    }

    .admin-links {
        width: 100%;
        flex-direction: column;
    }

    body.menu-open {
        padding-left: 0;
    }

    .site-footer {
        padding: 10px 0;
    }
    
    .site-footer p {
        font-size: 12px;
    }
}

/* Enhanced responsive design */
@media (max-width: 1024px) {
    .container {
        width: 95%;
        padding: 15px;
        padding-block-start: max(70px, 10vh);
    }
    
    .header {
        height: clamp(50px, 7vh, 70px);
    }

    header h1 {
        font-size: 2.2em;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .button:hover,
    .admin-link:hover {
        transform: none;
    }

    .button:active,
    .admin-link:active {
        transform: translateY(1px);
    }
}

/* Enhanced scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
    transition: var(--transition-base);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* Animation keyframes */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes expandContent {
    from {
        max-height: 0;
        opacity: 0;
    }
    to {
        max-height: var(--expanded-height);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Modern grid layout */
.grid {
    display: grid;
    gap: var(--space-md);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

/* Responsive breakpoints using modern container queries */
@container (min-width: 40em) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@container (min-width: 64em) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Utility classes */
.visually-hidden {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    block-size: 1px;
    inline-size: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
}

/* Enhanced a11y styles */
@media (prefers-reduced-motion: no-preference) {
    :root {
        scroll-behavior: smooth;
    }
}

/* Modal styling */
.modal {
    display: none;
    position: fixed;
    z-index: 2000; /* Ensure it's above all other elements */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.modal-content {
    background-color: var(--color-surface);
    padding: 2rem;
    border-radius: var(--border-radius);
    position: relative;
    width: 90%;
    max-width: 400px;
    margin: auto;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s ease-out;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    color: var(--color-text);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.close:hover {
    color: var(--color-primary);
}

/* Login form specific styles */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-form label {
    color: var(--color-text);
    font-weight: 500;
}

.login-form input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--color-surface-variant);
    border-radius: var(--border-radius);
    background-color: var(--color-surface-variant);
    color: var(--color-text);
    transition: border-color var(--transition-fast);
}

.login-form input:focus {
    border-color: var(--color-primary);
    outline: none;
}

.login-form button {
    background-color: var(--color-primary);
    color: black;
    padding: 0.75rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: bold;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.login-form button:hover {
    background-color: var(--color-primary-hover);
}

.error-message {
    color: var(--color-error);
    padding: 0.5rem;
    border-radius: var(--border-radius);
    background-color: rgba(244, 67, 54, 0.1);
    margin-top: 0.5rem;
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive header adjustments */
@media (max-width: 1024px) {
    .header {
        --header-height: 70px;
        padding: 0 var(--space-sm);
    }
    
    .content {
        padding-top: var(--header-height);
    }
}

@media (max-width: 768px) {
    .header {
        --header-height: 60px;
    }
    
    .content {
        padding-top: var(--header-height);
    }
    
    header h1 {
        font-size: clamp(1rem, 5vw, 1.5rem);
        letter-spacing: 1px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0 var(--space-xs);
        --header-height: 50px; /* Moved inside rule */
    }
    
    .content {
        padding-top: var(--header-height);
    }

    .container {
        padding-block-start: max(50px, 6vh);
    }

    header h1 {
        font-size: clamp(0.9rem, 4vw, 1.2rem);
        padding: 0 5px;
    }

    .site-footer {
        padding: 8px 0;
    }
}

/* Footer styling */
.site-footer {
    background-color: #232323;
    padding: 15px 0;
    text-align: center;
    width: 100%;
    border-top: 3px solid #ff8c00;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.site-footer p {
    margin: 0;
    color: #f1f1f1;
    font-size: 14px;
}

/* Dark mode specific styles */
body.dark-mode {
    background-color: #1a1a1a;
    color: #f1f1f1;
}

body.dark-mode .auth-container {
    background-color: #1a1a1a;
}

body.dark-mode .auth-box {
    background-color: #232323;
    border: 1px solid #333;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

body.dark-mode .form-group label {
    color: #e0e0e0;
}

body.dark-mode .form-group input {
    background-color: #2a2a2a;
    color: #f1f1f1;
    border: 1px solid #444;
}

body.dark-mode .form-text {
    color: #aaa;
}

body.dark-mode .btn-primary {
    background-color: #ff8c00;
    border-color: #ff8c00;
}

body.dark-mode .btn-primary:hover {
    background-color: #e07b00;
    border-color: #e07b00;
}

body.dark-mode .form-links a {
    color: #ff8c00;
}
