/**
 * D&D 5e Level-Up Tool - Enhanced Styles
 * A modern, responsive design for the comprehensive character progression assistant
 */

/* ===== CSS Variables ===== */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #48bb78;
    --warning-color: #f6ad55;
    --danger-color: #f56565;
    --info-color: #4299e1;

    --text-primary: #2d3748;
    --text-secondary: #718096;
    --text-light: #a0aec0;

    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-dark: #1a202c;
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;

    --border-color: #e2e8f0;
    --border-radius: 8px;
    --border-radius-lg: 15px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.2);

    --transition: all 0.3s ease;

    --font-body: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-heading: 'Georgia', serif;
}

/* ===== Dark Mode Variables ===== */
[data-theme="dark"] {
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --text-light: #718096;

    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --bg-dark: #0d1117;
    --bg-gradient-start: #4a5568;
    --bg-gradient-end: #2d3748;

    --border-color: #4a5568;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.5);
}

/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
}

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

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 32, 44, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* ===== Header ===== */
.app-header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 30px 0;
    text-align: center;
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
}

.app-title {
    font-size: 2.5rem;
    font-family: var(--font-heading);
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.app-subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 10px 16px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 20px;
    transition: var(--transition);
    backdrop-filter: blur(5px);
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}


/* ===== Main Content ===== */
main {
    padding: 30px 0 50px;
}

.main-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 30px;
    margin-bottom: 30px;
}

/* ===== Forms ===== */
.input-section {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 30px;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-help {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ===== Buttons ===== */
.btn {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn:disabled {
    background: var(--text-light);
    color: white;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

/* ===== Class/Subclass Info ===== */
.class-info-panel {
    background: var(--bg-secondary);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-top: 15px;
}

.class-info-panel h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.class-description {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 15px;
    font-style: italic;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.info-item {
    font-size: 14px;
}

.info-item strong {
    color: var(--text-primary);
}

/* ===== Results Section ===== */
.results-section {
    animation: slideUp 0.3s ease;
}

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

.results-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 25px;
    border-radius: var(--border-radius-lg);
    margin-bottom: 25px;
    text-align: center;
}

.results-header h2 {
    font-size: 2rem;
    margin-bottom: 5px;
}

.class-info {
    font-size: 1.1rem;
    opacity: 0.95;
}

.copy-link-btn {
    margin-top: 15px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    transition: var(--transition);
}

.copy-link-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.copy-link-btn.success {
    background: var(--success-color);
    border-color: var(--success-color);
}

/* ===== Category Sections ===== */
.category {
    background: var(--bg-secondary);
    border-left: 4px solid var(--primary-color);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: var(--border-radius);
}

.category h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.item {
    margin-bottom: 12px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.item strong {
    color: var(--text-primary);
    display: inline-block;
    margin-right: 10px;
}

.item.info-note {
    background: var(--bg-gradient-end);
    border-left: 3px solid var(--secondary-color);
    color: var(--text-secondary);
}

/* ===== Features ===== */
.feature-item {
    margin-bottom: 15px;
    padding: 0;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.feature-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    cursor: pointer;
}

.feature-name {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 16px;
}

.feature-toggle {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

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

.toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

.feature-description {
    padding: 0 15px 15px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.feature-description p {
    margin-bottom: 10px;
}

.feature-description p:last-child {
    margin-bottom: 0;
}

.subclass-feature {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-left: 4px solid var(--secondary-color);
}

/* ===== Spell Table ===== */
.spell-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.spell-table th,
.spell-table td {
    padding: 10px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.spell-table th {
    background: var(--primary-color);
    color: white;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.spell-table td {
    background: var(--bg-primary);
}

.spell-table .new-slot {
    background: var(--success-color);
    color: white;
    font-weight: 600;
}

.slot-change {
    font-size: 11px;
    vertical-align: super;
}

/* ===== Tags and Badges ===== */
.source-tag {
    display: inline-block;
    background: var(--text-secondary);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.source-badge {
    display: inline-block;
    background: var(--text-light);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

.subclass-tag {
    background: var(--secondary-color);
}

/* ===== Proficiencies & Equipment ===== */
.proficiency-section {
    margin-bottom: 15px;
}

.proficiency-section h4 {
    color: var(--primary-color);
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 600;
}

.proficiency-list {
    color: var(--text-primary);
    margin: 5px 0;
    padding-left: 10px;
}

.proficiency-choice {
    color: var(--text-primary);
    margin: 5px 0;
    padding-left: 10px;
    font-weight: 500;
}

.proficiency-choice::before {
    content: '✓ ';
    color: var(--success-color);
    font-weight: bold;
}

.equipment-note {
    font-style: italic;
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-size: 14px;
}

.equipment-choice {
    padding: 10px;
    margin: 8px 0;
    background: var(--bg-secondary);
    border-left: 3px solid var(--primary-color);
    border-radius: 4px;
}

.choice-number {
    color: var(--primary-color);
    font-weight: 700;
    margin-right: 5px;
}

.equipment-alternative {
    margin-top: 15px;
    padding: 12px;
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
}

.change-indicator {
    color: var(--success-color);
    font-weight: 600;
    margin-left: 5px;
}

.old-value {
    color: var(--text-light);
    text-decoration: line-through;
}

.new-value {
    color: var(--success-color);
    font-weight: 600;
}

/* ===== Fluff Text ===== */
.fluff-text {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 12px;
    text-align: justify;
}

.fluff-text:last-child {
    margin-bottom: 0;
}

/* ===== Notes ===== */
.note-item {
    display: flex;
    align-items: flex-start;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    margin-bottom: 10px;
}

.note-icon {
    font-size: 20px;
    margin-right: 12px;
    flex-shrink: 0;
}

.note-text {
    flex: 1;
    line-height: 1.5;
}

.note-tier {
    border-left: 4px solid var(--success-color);
    background: rgba(72, 187, 120, 0.1);
}

.note-important {
    border-left: 4px solid var(--warning-color);
    background: rgba(246, 173, 85, 0.1);
}

.note-choice {
    border-left: 4px solid var(--info-color);
    background: rgba(66, 153, 225, 0.1);
}

.note-spellcasting {
    border-left: 4px solid var(--secondary-color);
    background: rgba(118, 75, 162, 0.1);
}

/* ===== Welcome Box ===== */
.welcome-box {
    background: var(--bg-primary);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-lg);
    padding: 25px;
    text-align: center;
    margin-top: 20px;
    margin-bottom: 25px;
}

.welcome-box h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

/* ===== Error Message ===== */
.error-message {
    background: var(--danger-color);
    color: white;
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    text-align: center;
}

/* ===== HP Options ===== */
.hp-options {
    margin-top: 10px;
}

.hp-option {
    padding: 8px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
}

.hp-label {
    font-weight: 600;
    color: var(--text-secondary);
    display: inline-block;
    width: 80px;
}

.hp-value {
    color: var(--text-primary);
}

/* ===== Feature Descriptions ===== */
.feature-subsection {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.subsection-title {
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
}

.feature-list {
    margin: 10px 0 10px 20px;
}

.feature-list li {
    margin-bottom: 5px;
}

.feature-table {
    width: 100%;
    margin: 10px 0;
    border-collapse: collapse;
}

.feature-table caption {
    font-weight: 600;
    margin-bottom: 10px;
    text-align: left;
}

.feature-table th,
.feature-table td {
    padding: 8px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.feature-table th {
    background: var(--bg-secondary);
    font-weight: 600;
}

/* ===== Special Text Styles ===== */
.dice-roll {
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
}

.dice-roll:hover {
    text-decoration: underline;
}

.skill,
.condition,
.spell,
.item,
.creature,
.action {
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== Footer ===== */
.app-footer {
    background: var(--bg-dark);
    color: white;
    padding: 20px 0;
    text-align: center;
    margin-top: 50px;
}

.app-footer p {
    margin-bottom: 5px;
    opacity: 0.8;
}

.app-footer a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
    transition: var(--transition);
}

.app-footer a:hover {
    color: white;
    opacity: 1;
}

.version-info {
    font-size: 12px;
    opacity: 0.6;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .app-title {
        font-size: 1.8rem;
    }

    .app-subtitle {
        font-size: 1rem;
    }

    .theme-toggle {
        top: 15px;
        right: 15px;
        padding: 8px 14px;
        font-size: 18px;
    }

    .main-card {
        padding: 20px;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .results-header h2 {
        font-size: 1.5rem;
    }

    .category {
        padding: 15px;
    }

    /* Touch-friendly feature toggles */
    .feature-toggle {
        padding: 12px;
        min-height: 44px;
        font-size: 16px;
    }

    /* Better spacing for mobile */
    .form-group {
        margin-bottom: 20px;
    }

    .form-control, select.form-control {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .app-header {
        padding: 20px 0;
    }

    .app-title {
        font-size: 1.5rem;
    }

    .theme-toggle {
        top: 10px;
        right: 10px;
        padding: 6px 12px;
    }

    .btn {
        padding: 12px 20px;
        font-size: 16px;
        min-height: 48px; /* Touch-friendly */
    }

    .category h3 {
        font-size: 1.1rem;
    }

    /* Stack equipment choices better on small screens */
    .equipment-choice {
        font-size: 14px;
    }

    /* Adjust fluff text for readability */
    .fluff-text {
        text-align: left;
        font-size: 14px;
    }
}