/* ==========================================
   1. DESIGN TOKENS (SYSTEM FOUNDATION)
========================================== */
:root {
    --primary: #333;
    --secondary: #555;
    --accent: #bbb;
    --bg: #f4f4f4;
    --text: #333;

    --radius: 8px;
    --shadow-sm: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.2);

    --transition: 0.3s ease;
}

/* ==========================================
   2. BASE RESET
========================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* ==========================================
   3. LAYOUT SYSTEM
========================================== */
header {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* ==========================================
   4. NAVIGATION COMPONENT
========================================== */
.navbar {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: var(--primary);
    color: white;
    padding: 1rem 2rem;
}

.nav-links {
    display: flex;
    flex-direction: column;
    list-style: none;
    gap: 15px;
}

.nav-links a {
    color: white;
    text-decoration: none;
    position: relative;
    transition: color var(--transition);
}

.nav-links a:hover {
    color: var(--accent);
}

.nav-links a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -5px;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width var(--transition);
}

.nav-links a:hover::after {
    width: 100%;
}

/* ==========================================
   5. SECTION LAYOUT (FIXED - NO GLOBAL CHILD RULES)
========================================== */
.content-section {
    margin: 40px auto;
    max-width: 1200px;
    padding: 0 15px;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* ==========================================
   6. SEARCH COMPONENT
========================================== */
.search-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.search-input-wrapper {
    flex: 1;
    max-width: 400px;
}

.search-input {
    width: 100%;
}

.clear-btn-inside {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    display: none;
}

/* better selector (more stable) */
.search-input:not(:placeholder-shown) + .clear-btn-inside {
    display: block;
}

/* ==========================================
   7. LOADER (STATE COMPONENT)
========================================== */
.loader {
    width: 40px;
    height: 40px;
    border: 4px solid #ddd;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

.loader.show {
    display: block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================
   8. PROJECTS GRID
========================================== */
.projects-grid {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

/* ==========================================
   9. PROJECT CARD COMPONENT
========================================== */
.project-card {
    width: 100%;
    max-width: 400px;
    display: grid;
    grid-template-rows: auto 1fr;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.card-image-wrapper {
    position: relative;
}

.card-image-wrapper img {
    width: 100%;
    display: block;
}

.category-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--secondary);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.card-content {
    padding: 20px;
    display: grid;
    gap: 10px;
}

.card-btn {
    padding: 10px;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    border-radius: var(--radius);
}

/* ==========================================
   10. FORM COMPONENT
========================================== */
.form-section {
    max-width: 500px;
    margin: 40px auto;
    background: white;
    padding: 20px;
    border-radius: var(--radius);
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}

input, select, textarea {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--primary);
    border-color: transparent;
}

.submit-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

/* Hover state */
.submit-btn:hover {
    background-color: var(--secondary);
    transform: translateY(-1px);
}

/* Active (click feedback) */
.submit-btn:active {
    transform: translateY(0);
}

/* Focus (accessibility) */
.submit-btn:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ==========================================
   11. FORM ALERT STATES
========================================== */
.form-alert {
    display: none;
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 5px;
}

.form-alert.error {
    background: #f8d7da;
    color: #842029;
}

.form-alert.success {
    background: #d1e7dd;
    color: #0f5132;
}


/* ==========================================
   12. RESPONSIVE DESIGN
========================================== */
@media (min-width: 601px) {
    .navbar {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .nav-links {
        flex-direction: row;
        gap: 20px;
    }
}