/* ============================================================================
   Spin Wheel Application - Modern Responsive CSS
   ============================================================================ */

/* ============================================================================
   CSS Variables & Theme System
   ============================================================================ */

:root {
    /* Vibrant Gradient Theme (Default) */
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --border-color: #e2e8f0;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.15);
    --btn-primary: #667eea;
    --btn-primary-hover: #5568d3;
    --btn-danger: #f56565;
    --btn-danger-hover: #e53e3e;
    --btn-success: #48bb78;
    --btn-success-hover: #38a169;
    --accent-color: #ed8936;
}

[data-theme="dark"] {
    --bg-gradient-start: #1a202c;
    --bg-gradient-end: #2d3748;
    --card-bg: rgba(45, 55, 72, 0.95);
    --text-primary: #f7fafc;
    --text-secondary: #cbd5e0;
    --border-color: #4a5568;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.4);
    --btn-primary: #805ad5;
    --btn-primary-hover: #6b46c1;
}

[data-theme="minimal"] {
    --bg-gradient-start: #f7fafc;
    --bg-gradient-end: #edf2f7;
    --card-bg: #ffffff;
    --text-primary: #1a202c;
    --text-secondary: #718096;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 6px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="nature"] {
    --bg-gradient-start: #48bb78;
    --bg-gradient-end: #2f855a;
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-primary: #22543d;
    --text-secondary: #2f855a;
    --btn-primary: #38a169;
    --btn-primary-hover: #2f855a;
}

[data-theme="retro"] {
    --bg-gradient-start: #ed64a6;
    --bg-gradient-end: #f6ad55;
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-primary: #742a2a;
    --text-secondary: #9c4221;
    --btn-primary: #ed8936;
    --btn-primary-hover: #dd6b20;
}

/* ============================================================================
   Base Styles & Reset
   ============================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ============================================================================
   Header
   ============================================================================ */

header {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.settings-btn:hover {
    background: var(--border-color);
    transform: rotate(90deg);
}

/* ============================================================================
   Main Container & Layout
   ============================================================================ */

main {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* ============================================================================
   Card Components
   ============================================================================ */

.card {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--btn-primary);
    padding-bottom: 0.5rem;
}

.card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

/* ============================================================================
   Wheel Section
   ============================================================================ */

.wheel-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

#wheel-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1;
}

#wheel {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    transition: transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99);
}

#arrow {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-top: 40px solid #e53e3e;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
    z-index: 10;
}

.wheel-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

#spin-btn {
    padding: 1rem 3rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, var(--btn-primary) 0%, var(--btn-primary-hover) 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#spin-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

#spin-btn:active:not(:disabled) {
    transform: translateY(0);
}

#spin-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================================================
   Control Section
   ============================================================================ */

.control-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.wheel-controls,
.options-panel {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

/* Wheel Selector */
.wheel-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.wheel-selector select {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.wheel-selector select option {
    background: var(--card-bg);
    color: var(--text-primary);
}

.wheel-selector select:focus {
    outline: none;
    border-color: var(--btn-primary);
}

.icon-btn {
    padding: 0.75rem;
    border: none;
    border-radius: 0.5rem;
    background: var(--btn-primary);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    min-width: 44px;
}

.icon-btn:hover {
    background: var(--btn-primary-hover);
    transform: scale(1.05);
}

.icon-btn.danger {
    background: var(--btn-danger);
}

.icon-btn.danger:hover {
    background: var(--btn-danger-hover);
}

/* Theme Selector */
.theme-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.theme-btn {
    flex: 1;
    min-width: 100px;
    padding: 0.6rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.theme-btn.active {
    border-color: var(--btn-primary);
    background: var(--btn-primary);
    color: white;
}

.theme-btn:hover {
    transform: translateY(-2px);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--btn-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--btn-primary-hover);
}

.btn-success {
    background: var(--btn-success);
    color: white;
}

.btn-success:hover {
    background: var(--btn-success-hover);
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--text-secondary);
    color: white;
}

/* ============================================================================
   Options Panel
   ============================================================================ */

.add-option-form {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 0.5rem;
}

.add-option-form input[type="text"] {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    background: var(--card-bg);
    color: var(--text-primary);
    transition: border-color 0.3s ease;
}

.add-option-form input[type="text"]:focus {
    outline: none;
    border-color: var(--btn-primary);
}

.add-option-form input[type="color"] {
    width: 60px;
    height: 44px;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
}

.add-option-form input[type="number"] {
    width: 70px;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    background: var(--card-bg);
    color: var(--text-primary);
}

.color-palette {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 0.5rem;
}

.color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.color-swatch:hover {
    transform: scale(1.15);
    border-color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Options List */
#options-list {
    list-style: none;
    max-height: 400px;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.option-item:hover {
    border-color: var(--btn-primary);
    transform: translateX(4px);
}

.option-color {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(0, 0, 0, 0.1);
}

.option-text {
    flex: 1;
    font-weight: 500;
}

.option-weight {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.weight-bar {
    width: 40px;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.weight-fill {
    height: 100%;
    background: var(--btn-primary);
    transition: width 0.3s ease;
}

.option-actions {
    display: flex;
    gap: 0.5rem;
}

.option-btn {
    padding: 0.4rem 0.6rem;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.option-btn.edit {
    background: var(--btn-primary);
    color: white;
}

.option-btn.delete {
    background: var(--btn-danger);
    color: white;
}

.option-btn:hover {
    transform: scale(1.05);
}

/* ============================================================================
   History Section
   ============================================================================ */

.history-section {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.history-header h2 {
    border: none;
    padding: 0;
    margin: 0;
}

.toggle-icon {
    transition: transform 0.3s ease;
    font-size: 1.2rem;
}

.history-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.history-content {
    margin-top: 1rem;
}

.history-content.collapsed {
    display: none;
}

.statistics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    padding: 1rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 0.5rem;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--btn-primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

#spin-history {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--card-bg);
    border-left: 4px solid;
    border-radius: 0.25rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.history-winner {
    font-weight: 600;
}

.history-time {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ============================================================================
   Modal Styles
   ============================================================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--card-bg);
    border-radius: 1.5rem;
    padding: 2.5rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    scrollbar-gutter: stable;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    position: relative;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.winner-display {
    text-align: center;
}

.winner-text {
    font-size: 3rem;
    font-weight: 700;
    margin: 1.5rem 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.modal-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 1rem;
}

/* ============================================================================
   Toast Notifications
   ============================================================================ */

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-hover);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 2000;
    animation: slideInRight 0.3s ease;
    max-width: 400px;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left: 4px solid var(--btn-success);
}

.toast.error {
    border-left: 4px solid var(--btn-danger);
}

.toast.info {
    border-left: 4px solid var(--btn-primary);
}

/* ============================================================================
   Loading Spinner
   ============================================================================ */

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
    }

    .add-option-form {
        grid-template-columns: 1fr;
    }

    .statistics {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    header {
        padding: 1rem;
    }

    h1 {
        font-size: 1.4rem;
    }

    main {
        padding: 1rem;
    }

    .card {
        padding: 1.5rem;
    }

    #spin-btn {
        padding: 0.8rem 2rem;
        font-size: 1rem;
    }

    .wheel-selector {
        flex-direction: column;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }

    .toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }

    .statistics {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .modal-content {
        padding: 1.5rem;
    }

    .winner-text {
        font-size: 2rem;
    }

    .option-item {
        flex-wrap: wrap;
    }

    .option-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ============================================================================
   Utility Classes
   ============================================================================ */

.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

.slide-in {
    animation: slideIn 0.5s ease;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ============================================================================
   Scrollbar Styling
   ============================================================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--btn-primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--btn-primary-hover);
}
