/* ==============================================
   COMPONENT-BASED CSS ARCHITECTURE
   ============================================== */

/* ==============================================
   INPUT COMPONENTS
   ============================================== */

/* Base Input Component */
.input {
    padding: var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: #f0ede9;
    color: var(--text);
    font-size: var(--font-size-base);
    transition: border-color var(--transition-fast);
    width: 100%;
}

.input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.25);
}

/* Input Variants */
.input--readonly {
    background-color: #f0ede9 !important;
    color: var(--text);
    font-weight: 500;
    cursor: pointer;
}

.input--compact {
    padding: var(--space-1);
    font-size: var(--font-size-xs);
}

/* Input Group Component */
.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

/* Input Label Component */
.input-label {
    font-weight: 500;
    color: var(--text);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-1);
}

.input-label--compact {
    font-size: var(--font-size-xs);
    margin-bottom: calc(var(--space-1) / 2);
}

/* Input Wrapper Component */
.input-wrapper {
    position: relative;
    width: 100%;
}

/* Select Component */
.select {
    background-color: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-1);
    font-size: var(--font-size-base);
    line-height: 1.2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: border-color var(--transition-fast);
    width: 100%;
}

.select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.25);
}

/* Select Variants */
.select--compact {
    font-size: var(--font-size-xs);
    min-height: 150px;
}

.select--compact option {
    padding: 4px 8px;
    background-color: var(--bg);
    color: var(--text);
}

/* Option highlighting for persistent dropdowns */
.select--compact option:checked,
.select--compact option:selected,
.select--compact option.selected-highlight,
.select--compact option[selected] {
    background-color: var(--brand) !important;
    color: white !important;
    font-weight: 500;
}

.select--compact option:hover {
    background-color: var(--bg-hover);
}

/* ==============================================
   CARD COMPONENTS  
   ============================================== */

/* Base Card Component */
.card {
    background-color: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

/* Card Variants */
.card--sidebar {
    background-color: #f7f6f3;
    padding: var(--space-2);
}

.card--content {
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
}

.card--minimal {
    background-color: var(--bg-muted);
    border: none;
    padding: var(--space-3);
}

/* ==============================================
   FORM COMPONENTS
   ============================================== */

/* Form Component */
.form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.form--compact {
    gap: var(--space-2);
}

/* Form Row Component */
.form-row {
    display: flex;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.form-row--compact {
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

/* ==============================================
   TAB COMPONENTS
   ============================================== */

/* Tab Navigation Component */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-4);
}

/* Tab Link Component */
.tab {
    display: inline-block;
    padding: var(--space-2) var(--space-3);
    text-decoration: none;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    font-weight: 500;
}

.tab:hover {
    color: var(--text);
    background-color: var(--bg-hover);
}

.tab--active,
.tab.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
    background-color: var(--bg);
}

.tab:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.25);
}

/* Tab Panels Component */
.tab-panels {
    position: relative;
}

.tab-panel {
    display: none;
}

.tab-panel--active,
.tab-panel.active {
    display: block;
}

/* ==============================================
   BUTTON COMPONENTS
   ============================================== */

/* Base Button Component */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--bg);
    color: var(--text);
    font-size: var(--font-size-base);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--brand);
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.25);
}

/* Button Variants */
.btn--primary {
    background-color: var(--brand);
    color: white;
    border-color: var(--brand);
}

.btn--primary:hover {
    background-color: var(--brand-dark);
}

.btn--secondary {
    background-color: transparent;
    color: var(--brand);
    border-color: var(--brand);
}

.btn--secondary:hover {
    background-color: var(--brand);
    color: white;
}

/* ==============================================
   LAYOUT COMPONENTS
   ============================================== */

/* Layout Grid Component */
.layout-grid {
    display: flex;
    gap: var(--column-gap);
    max-width: var(--max-w);
    margin: 0 auto;
    padding: var(--space-3);
    align-items: flex-start;
    contain: layout;
}

/* Layout Columns */
.layout-sidebar-left {
    flex: 0 0 var(--left-column-width);
    min-height: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    contain: layout style;
}

.layout-content {
    flex: 1;
    min-width: var(--center-min-width);
    max-width: calc(var(--max-w) - var(--left-column-width) - var(--right-column-width) - (var(--column-gap) * 2));
    contain: layout style;
}

.layout-sidebar-right {
    flex: 0 0 var(--right-column-width);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    background-color: #f7f6f3;
    border-radius: 6px;
    padding: 12px;
    border: 1px solid #e6e6e6;
    contain: layout style;
}

/* Responsive Layout */
@media (max-width: 1024px) {
    .layout-grid {
        flex-direction: column;
        gap: var(--space-3);
        padding: var(--space-3);
    }
    
    .layout-sidebar-left {
        flex: none;
        order: 1;
        min-height: auto;
        width: 100%;
    }
    
    .layout-content {
        order: 2;
        min-width: 0;
        max-width: none;
        flex: 1;
    }
    
    .layout-sidebar-right {
        flex: none;
        order: 3;
        width: 100%;
        flex-direction: row;
        gap: var(--space-3);
        align-items: flex-start;
    }
}

@media (max-width: 768px) {
    .layout-grid {
        padding: var(--space-2);
        gap: var(--space-2);
    }
    
    .layout-sidebar-left,
    .layout-content,
    .layout-sidebar-right {
        width: 100%;
        order: unset;
    }
    
    .layout-sidebar-right {
        flex-direction: column;
        gap: var(--space-2);
    }
}

/* ==============================================
   AD COMPONENTS
   ============================================== */

/* Base Ad Slot Component */
.ad-slot {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ad Slot Variants */
.ad-slot.sidebar {
    margin: 0 auto;
}

/* Left Sidebar Ad */
.layout-sidebar-left .ad-slot.sidebar {
    width: 160px;
    height: 600px;
}

.layout-sidebar-left .ad-placeholder {
    width: 160px;
    height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: var(--font-size-xs);
    text-align: center;
    padding: var(--space-3);
}

/* Right Sidebar Ad */
.layout-sidebar-right .ad-slot.sidebar {
    width: 200px;
    height: 250px;
    margin: 60px auto 0 auto;
}

.layout-sidebar-right .ad-placeholder {
    color: var(--muted);
    font-size: var(--font-size-xs);
    text-align: center;
    padding: var(--space-3);
}

/* Responsive Ad Components */
@media (max-width: 1024px) {
    .layout-sidebar-left .ad-slot.sidebar {
        width: 100%;
        max-width: 728px;
        height: 90px;
        margin: 0 auto var(--space-3) auto;
    }
    
    .layout-sidebar-left .ad-placeholder {
        width: 100%;
        height: 90px;
        max-width: 728px;
        margin: 0 auto;
    }
    
    .layout-sidebar-right .ad-slot.sidebar {
        flex: 0 0 300px;
        height: 250px;
        margin: 0;
    }
}

@media (max-width: 768px) {
    .layout-sidebar-left .ad-slot.sidebar {
        max-width: 320px;
        height: 50px;
        margin: 0 auto var(--space-2) auto;
    }
    
    .layout-sidebar-left .ad-placeholder {
        height: 50px;
        max-width: 320px;
    }
    
    .layout-sidebar-right .ad-slot.sidebar {
        flex: none;
        width: 100%;
        max-width: 300px;
        height: 250px;
        margin: 0 auto var(--space-2) auto;
    }
}

/* ==============================================
   UTILITY CLASSES
   ============================================== */

/* Spacing Utilities */
.u-p-0 { padding: 0; }
.u-p-1 { padding: var(--space-1); }
.u-p-2 { padding: var(--space-2); }
.u-p-3 { padding: var(--space-3); }
.u-p-4 { padding: var(--space-4); }

.u-m-0 { margin: 0; }
.u-m-1 { margin: var(--space-1); }
.u-m-2 { margin: var(--space-2); }
.u-m-3 { margin: var(--space-3); }
.u-m-4 { margin: var(--space-4); }

/* Display Utilities */
.u-flex { display: flex; }
.u-block { display: block; }
.u-inline { display: inline; }
.u-hidden { display: none; }

/* Text Utilities */
.u-text-center { text-align: center; }
.u-text-left { text-align: left; }
.u-text-right { text-align: right; }

.u-font-bold { font-weight: bold; }
.u-font-normal { font-weight: normal; }

/* Color Utilities */
.u-text-muted { color: var(--muted); }
.u-text-brand { color: var(--brand); }
.u-bg-muted { background-color: var(--bg-muted); }