/* ===================================
   7UP Account Builder Planner
   Main Stylesheet
   =================================== */

/* CSS Variables - OSRS Theme */
:root {
    /* OSRS Colors */
    --osrs-gold: #FFD700;
    --osrs-gold-dark: #B8860B;
    --osrs-bronze: #CD7F32;
    --osrs-red: #8B0000;
    --osrs-green: #00FF00;
    --osrs-blue: #4169E1;
    
    /* Primary Colors */
    --primary-color: #FFD700;
    --primary-hover: #FFA500;
    --secondary-color: #2c2416;
    --secondary-hover: #3d3220;
    --success-color: #00FF00;
    --warning-color: #FFA500;
    --danger-color: #FF0000;
    
    /* Background Colors - OSRS Stone/Wood Theme */
    --bg-primary: #1a1410;
    --bg-secondary: #2c2416;
    --bg-tertiary: #3d3220;
    --bg-hover: #4d4230;
    --bg-panel: linear-gradient(135deg, #2c2416 0%, #3d3220 100%);
    
    /* Text Colors */
    --text-primary: #FFD700;
    --text-secondary: #D4AF37;
    --text-muted: #8B7355;
    
    /* Border Colors - OSRS Style */
    --border-color: #5a4a2a;
    --border-hover: #6a5a3a;
    --border-gold: #FFD700;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.3);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
    width: 100%;
}

/* Header - gradient follows yellow line shape */
.header {
    background: linear-gradient(135deg, #1f1a13 0%, #2c2416 40%, #3d3220 100%);
    padding: var(--spacing-md) 0;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    position: sticky;
    top: 0;
    z-index: 100;
    margin-bottom: 0;
    position: relative;
    overflow: visible;
}

.header-shape {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.header-title h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

.header-title .subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-logo {
    height: 180px;
    width: auto;
    max-width: 600px;
    object-fit: contain;
    display: block;
    position: relative;
    z-index: 110;
    filter: drop-shadow(0 8px 24px rgba(255, 215, 0, 0.5))
            drop-shadow(0 0 40px rgba(255, 215, 0, 0.3));
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.header-logo:hover {
    transform: translateY(-25px) scale(1.02);
    filter: drop-shadow(0 12px 32px rgba(255, 215, 0, 0.6))
            drop-shadow(0 0 50px rgba(255, 215, 0, 0.4));
}

/* Header layout */
.header-bar {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: var(--spacing-md);
    padding: 0 var(--spacing-lg);
    width: 100%;
    position: relative;
    z-index: 101;
}

/* Position containers for mode buttons (all styling in mode-selector.css) */
.header-left,
.header-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.header-center {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 102;
}

.header-border {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    z-index: 100;
    pointer-events: none;
}

/* Top bar in header - menu left, rate limit text right */
.header-top-bar {
    position: absolute;
    top: 4px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--spacing-lg);
    z-index: 110;
    pointer-events: none;
}

.header-top-left {
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
}

.header-top-right {
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
}

/* Dropdown Menu Button */
.btn-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(45, 36, 22, 0.95);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 8px;
    color: #FFD700;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-menu:hover {
    background: rgba(61, 50, 32, 0.95);
    border-color: rgba(255, 215, 0, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* Rate limit display - styled box */
.header-top-right .rate-limit-display {
    padding: 5px 16px;
    background: rgba(45, 36, 22, 0.95);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 8px;
    text-align: right;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.header-top-right .rate-limit-display:hover {
    border-color: rgba(255, 215, 0, 0.6);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.header-top-right .rate-limit-text {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-top-right .rate-limit-label {
    font-size: 0.85rem;
    color: rgba(255, 215, 0, 0.8);
    font-weight: 500;
}

.header-top-right .rate-limit-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #FFD700;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
}

.header-top-right .rate-limit-subtext {
    display: none;
}

/* Hide API Key and Settings buttons from top bar */
.header-top-right #api-key-btn,
.header-top-right #open-settings-btn {
    display: none;
}

/* Rate Limit Display */
.rate-limit-display {
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: right;
}

.rate-limit-text {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.rate-limit-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.rate-limit-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-gold);
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.rate-limit-value.unlimited {
    color: #4CAF50;
}

.rate-limit-value.low {
    color: #ff9800;
}

.rate-limit-value.depleted {
    color: #f44336;
}

.rate-limit-subtext {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Control Toolbar - New Unified Design */
.control-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.toolbar-actions {
    display: flex;
    gap: 6px;
}

/* Toolbar Buttons */
.btn-toolbar {
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 215, 0, 0.25);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1;
}

.btn-toolbar:hover {
    background: rgba(255, 215, 0, 0.06);
    border-color: rgba(255, 215, 0, 0.6);
    color: var(--text-primary);
}

.btn-toolbar:active {
    transform: translateY(1px);
}

/* Variants use subtle accent borders instead of full-color fills */
.btn-toolbar.btn-primary {
    border-color: rgba(65, 105, 225, 0.7);
    color: #a5b9ff;
}

.btn-toolbar.btn-primary:hover {
    background: rgba(65, 105, 225, 0.18);
    border-color: rgba(65, 105, 225, 1);
    color: #dbe4ff;
}

.btn-toolbar.btn-warning {
    border-color: rgba(255, 165, 0, 0.7);
    color: #ffd8a0;
}

.btn-toolbar.btn-warning:hover {
    background: rgba(255, 165, 0, 0.18);
    border-color: rgba(255, 165, 0, 1);
    color: #fff3c4;
}

.btn-toolbar.btn-danger {
    border-color: rgba(220, 38, 38, 0.7);
    color: #fecaca;
}

.btn-toolbar.btn-danger:hover {
    background: rgba(220, 38, 38, 0.18);
    border-color: rgba(220, 38, 38, 1);
    color: #fee2e2;
}

/* Quick Select Dropdown */
.quick-select-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
}

.preset-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    border: 2px solid var(--border-gold);
    border-radius: 4px;
    padding: 2px;
    background: var(--bg-tertiary);
}

.quick-select-container #save-preset-btn,
.quick-select-container #delete-preset-btn {
    padding: 8px 12px;
    min-width: 40px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quick-select-container #save-preset-btn:hover {
    transform: scale(1.1);
    background: var(--bg-hover);
    border-color: var(--border-gold);
}

.quick-select-container #delete-preset-btn {
    background: var(--bg-tertiary);
    border-color: var(--danger-color);
}

.quick-select-container #delete-preset-btn:hover {
    transform: scale(1.1);
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
}

.quick-select-container label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.quick-select-dropdown {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    padding-left: 32px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 180px;
    background-repeat: no-repeat;
    background-position: 6px center;
    background-size: 18px 18px;
}

.quick-select-dropdown[data-selected-icon] {
    background-image: var(--selected-icon);
}

.quick-select-dropdown:hover {
    border-color: var(--border-gold);
    background: var(--bg-hover);
}

.quick-select-dropdown:focus {
    outline: none;
    border-color: var(--border-gold);
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.2);
}

.quick-select-dropdown option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: var(--spacing-sm);
    padding-left: 32px;
    background-repeat: no-repeat;
    background-position: 4px center;
    background-size: 20px 20px;
}

/* Add icons to specific preset options */
.quick-select-dropdown option[value="maxed"] {
    background-image: url('../assets/icons/max.png');
}

.quick-select-dropdown option[value="pure"] {
    background-image: url('../assets/icons/pure.png');
}

.quick-select-dropdown option[value="zerker"] {
    background-image: url('../assets/icons/torso.png');
}

.quick-select-dropdown option[value="main"] {
    background-image: url('../assets/icons/main.png');
}

.quick-select-dropdown option[value="sote"] {
    background-image: url('../assets/icons/song.png');
}

.quick-select-dropdown option[value="questcape"] {
    background-image: url('../assets/icons/quests.png');
}

/* Main Container */
.main-container {
    flex: 1;
    padding: var(--spacing-xl) 0;
}

/* Section - OSRS panel styling */
.section {
    background: var(--bg-panel);
    border-radius: 14px;
    border: 2px solid #6a5a3a;
    outline: 3px solid rgba(0,0,0,0.35);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.section:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.55);
}

.section h2 {
    font-size: 1.6rem;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-gold);
    padding-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Row with title and actions */
.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

/* Skill goals header actions (Quick Select + Generate button) */
.skill-goals-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.quick-select-inline {
    display: flex;
    align-items: center;
    gap: 6px;
}

.quick-select-inline .toolbar-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.section h3 {
    font-size: 1.3rem;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.section-description {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
    font-size: 0.95rem;
}

/* Settings Group */
.settings-group {
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.settings-group:last-child {
    margin-bottom: 0;
}

/* Setting Item */
.setting-item {
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.setting-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.setting-description {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: var(--spacing-xs);
    margin-left: 56px;
}

/* Toggle Label */
.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 48px;
    height: 24px;
    background-color: var(--bg-hover);
    border-radius: 12px;
    transition: background-color var(--transition-normal);
    margin-right: var(--spacing-sm);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: white;
    top: 2px;
    left: 2px;
    transition: transform var(--transition-normal);
}

.toggle-label input[type="checkbox"]:checked + .toggle-slider {
    background-color: var(--success-color);
}

.toggle-label input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.toggle-text {
    font-weight: 500;
    font-size: 1rem;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: var(--spacing-md) var(--spacing-xl);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: linear-gradient(135deg, rgba(255,215,0,0.15) 0%, rgba(255,165,0,0.1) 100%), #4d3f25;
    border: 2px solid var(--border-gold);
    color: var(--text-primary);
}

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

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

.btn-secondary {
    background: linear-gradient(135deg, rgba(106,90,58,0.25), rgba(77,63,37,0.25));
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    outline: 1px solid rgba(0,0,0,0.35);
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-hover);
}

.btn-large {
    font-size: 1.2rem;
    padding: var(--spacing-lg) var(--spacing-xl);
    width: 100%;
    max-width: 400px;
    display: block;
    margin: 0 auto;
}

/* Total Level Display */
.total-level {
    text-align: center;
    font-size: 1.3rem;
    font-weight: bold;
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background: linear-gradient(180deg, rgba(255,215,0,0.08), rgba(255,215,0,0.03));
    border: 2px solid var(--border-gold);
    border-radius: 10px;
    color: var(--text-primary);
}

/* Footer */
.footer {
    background-color: var(--bg-secondary);
    padding: var(--spacing-lg) 0;
    text-align: center;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 2000;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(900px, 92vw);
    max-height: 80vh;
    overflow: hidden;
    background: var(--bg-panel);
    border-radius: 14px;
    border: 2px solid #6a5a3a;
    outline: 3px solid rgba(0,0,0,0.35);
    box-shadow: 0 18px 40px rgba(0,0,0,0.6);
    z-index: 11000; /* above loading overlay */
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 2px solid var(--border-gold);
}

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
}

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
}

.modal-group { margin-bottom: var(--spacing-lg); }
.modal-group h4 { color: var(--text-secondary); margin-bottom: var(--spacing-md); }

/* Inline spinner for plan modal */
.inline-spinner {
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 8px;
}

.plan-generating {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

/* Plan progress bar */
.plan-progress {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid #00ff88;
    border-radius: 8px;
    overflow: hidden;
    margin: var(--spacing-md) 0;
    box-shadow: inset 0 0 8px rgba(0, 255, 136, 0.35), 0 0 10px rgba(0, 255, 136, 0.2);
}
.plan-progress-bar {
    height: 100%;
    width: 0%;
    background-image:
        linear-gradient(90deg, #00ff99, #00d26a),
        repeating-linear-gradient(45deg, rgba(255,255,255,0.25) 0 10px, rgba(255,255,255,0.05) 10px 20px);
    background-blend-mode: overlay;
    transition: width 0.2s ease;
    box-shadow: 0 0 14px rgba(0, 255, 136, 0.6);
    animation: progressStripes 1s linear infinite;
}

@keyframes progressStripes {
    from { background-position: 0 0, 0 0; }
    to { background-position: 40px 0, 40px 0; }
}

/* Tabs (Settings Modal) */
.tabs { display: block; }
.tab-header {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--border-color);
}
.tab-btn {
    padding: 8px 14px;
    background: linear-gradient(135deg, rgba(106,90,58,0.2), rgba(77,63,37,0.2));
    border: 1px solid var(--border-color);
    border-bottom: none;
    color: var(--text-secondary);
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    cursor: pointer;
}
.tab-btn.active {
    background: linear-gradient(135deg, rgba(255,215,0,0.12), rgba(255,165,0,0.08));
    color: var(--text-primary);
    border: 1px solid var(--border-gold);
    border-bottom: 2px solid var(--bg-panel);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 12px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

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