/* ========================================
   Google Material Design - Font Import
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

/* ========================================
   CSS Reset & Base Styles
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Material Design Colors */
    --md-primary: #3F51B5;
    --md-primary-dark: #303F9F;
    --md-primary-light: #C5CAE9;
    --md-accent: #E91E63;
    --md-accent-light: #F8BBD0;
    --md-background: #FAFAFA;
    --md-surface: #FFFFFF;
    --md-error: #F44336;
    --md-success: #4CAF50;

    /* Material Design Text Colors */
    --md-text-primary: rgba(0, 0, 0, 0.87);
    --md-text-secondary: rgba(0, 0, 0, 0.6);
    --md-text-disabled: rgba(0, 0, 0, 0.38);
    --md-text-hint: rgba(0, 0, 0, 0.38);
    --md-text-on-primary: rgba(255, 255, 255, 1);
    --md-text-on-accent: rgba(255, 255, 255, 1);

    /* Material Design Elevations (Shadows) */
    --md-elevation-1: 0 2px 1px -1px rgba(0,0,0,0.2), 0 1px 1px 0 rgba(0,0,0,0.14), 0 1px 3px 0 rgba(0,0,0,0.12);
    --md-elevation-2: 0 3px 1px -2px rgba(0,0,0,0.2), 0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12);
    --md-elevation-3: 0 3px 3px -2px rgba(0,0,0,0.2), 0 3px 4px 0 rgba(0,0,0,0.14), 0 1px 8px 0 rgba(0,0,0,0.12);
    --md-elevation-4: 0 2px 4px -1px rgba(0,0,0,0.2), 0 4px 5px 0 rgba(0,0,0,0.14), 0 1px 10px 0 rgba(0,0,0,0.12);
    --md-elevation-6: 0 3px 5px -1px rgba(0,0,0,0.2), 0 6px 10px 0 rgba(0,0,0,0.14), 0 1px 18px 0 rgba(0,0,0,0.12);
    --md-elevation-8: 0 5px 5px -3px rgba(0,0,0,0.2), 0 8px 10px 1px rgba(0,0,0,0.14), 0 3px 14px 2px rgba(0,0,0,0.12);

    /* Material Design Transitions */
    --md-transition-standard: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --md-transition-deceleration: 0.4s cubic-bezier(0, 0, 0.2, 1);
    --md-transition-acceleration: 0.2s cubic-bezier(0.4, 0, 1, 1);
    --md-transition-sharp: 0.2s cubic-bezier(0.4, 0, 0.6, 1);

    /* Material Design Border Radius */
    --md-radius-small: 2px;
    --md-radius-medium: 4px;
    --md-radius-large: 8px;

    /* Legacy Variables (for compatibility) */
    --border-radius: 4px;
    --transition-speed: 0.3s;
    --shadow: rgba(0, 0, 0, 0.14);
    --overlay-bg: rgba(0, 0, 0, 0.7);
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.5;
    color: var(--md-text-primary);
    background: var(--md-background);
    overflow-x: hidden;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Ad Containers
   ======================================== */

.ad-container {
    background: transparent; /* Clean background */
    padding: 0; /* No padding */
    text-align: center;
    border: none; /* No borders */
}

.ad-placeholder {
    display: none; /* Hide placeholder */
}

.ad-anchor {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    border: none; /* No borders */
}

/* ========================================
   Layout Wrapper (3-Column Grid for Desktop)
   ======================================== */

.layout-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Sidebar Ads - Hidden on Mobile/Tablet */
.sidebar-ad {
    display: none;
}

.sidebar-ad-placeholder {
    display: none; /* Hide placeholder */
}

.ad-size-label {
    display: none; /* Hide size label */
}

/* Desktop: Show 3-Column Layout */
@media (min-width: 1280px) {
    .layout-wrapper {
        display: grid;
        grid-template-columns: 300px 1fr 300px;
        gap: 20px;
        max-width: 1920px;
        margin: 0 auto;
        padding: 0 20px;
    }

    .sidebar-ad {
        display: block;
        position: sticky;
        top: 150px; /* Below controls */
        align-self: start;
        max-height: calc(100vh - 240px);
        overflow: hidden;
    }

    .left-sidebar {
        grid-column: 1;
    }

    .app-container {
        grid-column: 2;
        max-width: 1200px;
        margin: 0 auto;
    }

    .right-sidebar {
        grid-column: 3;
    }
}

/* Large Desktop: More Spacing */
@media (min-width: 1600px) {
    .layout-wrapper {
        gap: 30px;
    }
}

/* Desktop: No position constraints needed (static layout) */

/* Desktop: Constrain Shortcuts Info */
@media (min-width: 1280px) {
    .shortcuts-info {
        right: calc(340px + 20px); /* Keep within main content area */
    }
}

@media (min-width: 1600px) {
    .shortcuts-info {
        right: calc(350px + 20px);
    }
}

/* ========================================
   Main App Container
   ======================================== */

.app-container {
    display: flex;
    flex-direction: column;
    background: var(--md-surface);
    min-height: calc(100vh - 140px); /* Full height minus top/bottom ads */
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    box-shadow: var(--md-elevation-2);
    border-radius: var(--md-radius-medium);
    overflow: visible;
}

/* ========================================
   Application Header
   ======================================== */

.app-header {
    background: white;
    padding: 24px 24px 20px;
    text-align: center;
    box-shadow: var(--md-elevation-2);
    border-radius: var(--md-radius-medium) var(--md-radius-medium) 0 0;
}

.app-title {
    font-size: 28px;
    font-weight: 900;
    font-family: 'Roboto', 'Arial Black', sans-serif;
    color: var(--md-primary);
    margin: 0;
    letter-spacing: 1.5px;
    line-height: 1.2;
}

.app-tagline {
    font-size: 14px;
    font-weight: 400;
    color: var(--md-text-secondary);
    margin: 8px 0 0;
    letter-spacing: 0.25px;
}

/* ========================================
   Controls Panel
   ======================================== */

.controls-panel {
    position: relative; /* Need position for z-index */
    background: var(--md-surface);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 1;
    box-shadow: var(--md-elevation-1);
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
    min-height: 64px; /* Material Design app bar height */
    flex-shrink: 0;
}

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

.control-group label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.color-count-selector,
.harmony-selector,
.accessibility-selector {
    padding: 8px 16px;
    border: 1px solid rgba(0, 0, 0, 0.23);
    border-radius: var(--md-radius-medium);
    background: var(--md-surface);
    font-size: 14px;
    font-family: 'Roboto', sans-serif;
    color: var(--md-text-primary);
    cursor: pointer;
    transition: all var(--md-transition-standard);
}

.color-count-selector:hover,
.harmony-selector:hover,
.accessibility-selector:hover {
    border-color: rgba(0, 0, 0, 0.87);
    background: rgba(0, 0, 0, 0.04);
}

.color-count-selector:focus,
.harmony-selector:focus,
.accessibility-selector:focus {
    border-color: var(--md-primary);
    border-width: 2px;
    padding: 7px 15px; /* Adjust for thicker border */
    outline: none;
    box-shadow: 0 0 0 2px rgba(63, 81, 181, 0.12);
}

.icon-btn {
    padding: 8px;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.23);
    border-radius: var(--md-radius-medium);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--md-transition-standard);
    min-width: 40px;
    min-height: 40px;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.87);
}

.icon-btn:active {
    background: rgba(0, 0, 0, 0.12);
}

.faq-text-btn {
    padding: 8px 12px;
}

.faq-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--md-text-primary);
    letter-spacing: 0.5px;
}

/* ========================================
   Palette Container
   ======================================== */

.palette-container {
    flex: 1; /* Fill available space between controls and action panel */
    display: flex;
    margin: 0; /* No margins needed - contained layout */
    min-height: 400px;
    position: relative;
    z-index: 2;
}

.color-swatch {
    flex: 1;
    position: relative;
    cursor: pointer;
    transition: all var(--md-transition-standard);
    min-height: 400px;
    z-index: 1;
    overflow: visible; /* Allow interactive elements to extend beyond bounds */
}

.color-swatch:hover {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2);
    z-index: 5;
}

.color-swatch:active {
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.3);
}

/* Lock Button - Material Design FAB Style */
.lock-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: var(--md-surface);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--md-transition-standard);
    box-shadow: var(--md-elevation-2);
    z-index: 10; /* Above other swatch elements */
}

.lock-btn:hover {
    box-shadow: var(--md-elevation-4);
    transform: scale(1.05);
}

.lock-btn:active {
    box-shadow: var(--md-elevation-6);
}

.lock-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--md-text-secondary);
}

.lock-btn.locked {
    background: var(--md-primary);
}

.lock-btn.locked svg {
    stroke: var(--md-text-on-primary);
}

/* Refresh Button - Material Design FAB Style */
.refresh-btn {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 40px;
    height: 40px;
    background: var(--md-surface);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--md-transition-standard);
    box-shadow: var(--md-elevation-2);
    z-index: 10; /* Above other swatch elements */
}

.refresh-btn:hover {
    box-shadow: var(--md-elevation-4);
    transform: scale(1.05);
}

.refresh-btn:active {
    box-shadow: var(--md-elevation-6);
}

.refresh-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--md-text-secondary);
}

/* Color Code Display */
.color-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    text-align: center;
}

.color-code {
    font-size: 18px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    display: inline-block;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    transition: all var(--transition-speed);
}

.color-code:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.format-toggle {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: opacity var(--md-transition-standard);
}

.format-toggle:hover {
    opacity: 1;
}

/* Contrast Badge - Material Design Chip */
.contrast-badge {
    position: absolute;
    top: 64px;
    right: 16px;
    background: rgba(255, 255, 255, 0.95);
    padding: 6px 12px;
    border-radius: 16px; /* Material chip radius */
    font-size: 11px;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    box-shadow: var(--md-elevation-1);
    letter-spacing: 0.3px;
    cursor: help; /* Show question mark cursor on hover */
    user-select: none;
    z-index: 10; /* Above other swatch elements */
    pointer-events: auto; /* Ensure clickable on touch devices */
}

.contrast-badge.aa {
    background: var(--md-success);
    color: var(--md-text-on-primary);
}

.contrast-badge.aaa {
    background: var(--md-primary);
    color: var(--md-text-on-primary);
}

.contrast-badge.fail {
    background: var(--md-error);
    color: var(--md-text-on-primary);
}

/* Tooltip for Contrast Badges - White Background Design */
.contrast-tooltip {
    position: fixed; /* Fixed positioning to avoid clipping */
    left: 0;
    top: 0;
    background: white;
    color: var(--md-text-primary);
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.24), 0 2px 4px rgba(0,0,0,0.12);
    border: 1px solid rgba(0,0,0,0.08);
    min-width: 280px;
    max-width: 500px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    z-index: 9999; /* Overlay everything */
    pointer-events: none;
    font-size: 13px;
    line-height: 1.7;
    white-space: normal;
    text-align: left;
}

/* Tooltip arrow pointing UP to badge */
.contrast-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%; /* Position at top of tooltip */
    left: 50%;
    transform: translateX(-50%);
    border: 7px solid transparent;
    border-bottom-color: white; /* Arrow points up to badge */
    filter: drop-shadow(0 -2px 2px rgba(0,0,0,0.1));
}

/* Show tooltip on hover with delay */
.contrast-badge:hover .contrast-tooltip {
    opacity: 1;
    visibility: visible;
    transition-delay: 0.3s; /* 300ms delay before showing */
}

/* Tooltip Sections */
.tooltip-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--md-text-primary);
}

.tooltip-ratio {
    font-size: 13px;
    font-weight: 500;
    color: var(--md-text-secondary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.tooltip-section {
    margin-bottom: 12px;
}

.tooltip-section:last-child {
    margin-bottom: 0;
}

.tooltip-section-title {
    font-weight: 500;
    color: var(--md-text-primary);
    margin-bottom: 6px;
    font-size: 13px;
}

.tooltip-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.tooltip-list li {
    padding-left: 16px;
    margin-bottom: 4px;
    position: relative;
    color: var(--md-text-secondary);
    font-size: 12px;
}

.tooltip-list li:last-child {
    margin-bottom: 0;
}

.tooltip-list li::before {
    content: '•';
    position: absolute;
    left: 0;
    font-weight: bold;
    color: var(--md-text-primary);
}

/* ========================================
   Action Panel
   ======================================== */

.action-panel {
    position: relative; /* Need position for z-index */
    background: var(--md-surface);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 1;
    box-shadow: var(--md-elevation-1);
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 0 0 var(--md-radius-medium) var(--md-radius-medium);
    min-height: 72px; /* Material Design bottom bar height */
    flex-shrink: 0;
}

.generate-btn {
    /* Material Design Contained Button */
    padding: 10px 24px;
    background: var(--md-primary);
    color: var(--md-text-on-primary);
    border: none;
    border-radius: var(--md-radius-medium);
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all var(--md-transition-standard);
    box-shadow: var(--md-elevation-2);
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    font-family: 'Roboto', sans-serif;
}

.generate-btn:hover {
    background: var(--md-primary-dark);
    box-shadow: var(--md-elevation-4);
}

.generate-btn:active {
    box-shadow: var(--md-elevation-6);
}

.secondary-btn {
    /* Material Design Outlined Button */
    padding: 9px 23px; /* 1px less for border */
    background: transparent;
    color: var(--md-primary);
    border: 1px solid var(--md-primary);
    border-radius: var(--md-radius-medium);
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all var(--md-transition-standard);
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    font-family: 'Roboto', sans-serif;
}

.secondary-btn:hover {
    background: rgba(63, 81, 181, 0.08); /* Primary with 8% opacity */
    border-color: var(--md-primary-dark);
}

.secondary-btn:active {
    background: rgba(63, 81, 181, 0.16); /* Primary with 16% opacity */
}

.shortcut-hint {
    font-size: 11px;
    opacity: 0.7;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

/* ========================================
   Modals
   ======================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-speed);
}

.close-btn:hover {
    transform: scale(1.1);
}

/* History List */
.history-list {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
}

.history-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--md-elevation-1);
    transition: box-shadow var(--transition-speed), border-color var(--transition-speed);
}

.history-item:hover {
    box-shadow: var(--md-elevation-2);
    border-color: var(--md-primary);
}

/* History Header */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.history-index {
    font-size: 14px;
    font-weight: 700;
    color: var(--md-primary);
}

.history-timestamp {
    font-size: 12px;
    color: #999;
}

/* History Body - Color Swatches */
.history-body {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.history-color-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-color {
    height: 50px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.history-color-code {
    font-size: 10px;
    font-family: 'Courier New', monospace;
    color: #666;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* History Footer */
.history-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.history-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.history-badge {
    font-size: 11px;
    padding: 4px 10px;
    background: #f5f5f5;
    border-radius: 12px;
    color: #666;
    font-weight: 500;
}

.history-actions {
    display: flex;
    gap: 8px;
}

.history-action-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #666;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.history-action-btn:hover {
    background: var(--md-primary);
    border-color: var(--md-primary);
    color: white;
}

.history-action-btn.delete-btn:hover {
    background: #f44336;
    border-color: #f44336;
    color: white;
}

.history-action-btn svg {
    width: 14px;
    height: 14px;
}

/* Shortcuts List */
.shortcuts-list {
    padding: 20px 25px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.shortcut-item:last-child {
    border-bottom: none;
}

kbd {
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 4px;
    padding: 4px 12px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: 600;
    min-width: 50px;
    text-align: center;
}

.shortcut-item span {
    flex: 1;
    color: #666;
    font-size: 14px;
}

/* FAQ List */
.faq-content {
    max-width: 700px;
}

.faq-list {
    padding: 20px 25px;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
}

.faq-item {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f0f0f0;
}

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

.faq-item h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--md-primary);
    margin: 0 0 12px 0;
    line-height: 1.4;
}

.faq-item p {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin: 0 0 12px 0;
}

.faq-item p:last-child {
    margin-bottom: 0;
}

.faq-item ul {
    margin: 8px 0 12px 0;
    padding-left: 24px;
}

.faq-item li {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 8px;
}

.faq-item li:last-child {
    margin-bottom: 0;
}

.faq-item strong {
    color: #333;
    font-weight: 600;
}

.faq-item kbd {
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 4px;
    padding: 2px 8px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    font-weight: 600;
}

/* Contrast Modal Body */
.contrast-modal-body {
    padding: 20px 25px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

.contrast-modal-body .tooltip-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 16px;
    color: var(--md-text-primary);
}

.contrast-modal-body .tooltip-ratio {
    font-size: 14px;
    font-weight: 500;
    color: var(--md-text-secondary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.contrast-modal-body .tooltip-section {
    margin-bottom: 16px;
}

.contrast-modal-body .tooltip-section-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--md-text-primary);
}

.contrast-modal-body .tooltip-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.contrast-modal-body .tooltip-list li {
    padding: 4px 0 4px 8px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--md-text-secondary);
    position: relative;
}

.contrast-modal-body p {
    margin-bottom: 12px;
    line-height: 1.6;
    color: var(--md-text-secondary);
}

.contrast-modal-body ul {
    margin: 8px 0 12px 0;
    list-style: none;
}

.contrast-modal-body strong {
    color: var(--md-text-primary);
    font-weight: 600;
}

/* ========================================
   Toast Notification
   ======================================== */

.toast {
    position: fixed;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 14px;
    z-index: 2000;
    animation: toastSlide 0.3s ease;
}

.toast.hidden {
    display: none;
}

@keyframes toastSlide {
    from {
        transform: translateX(-50%) translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* ========================================
   Hidden Elements
   ======================================== */

.hidden-picker {
    position: fixed;
    width: 1px;
    height: 1px;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
}

/* ========================================
   Mobile Responsive (320px+)
   ======================================== */

@media (max-width: 768px) {
    .app-container {
        border-radius: 0; /* Full width on mobile */
        min-height: 100vh;
        max-height: 100vh; /* Fit everything on screen */
    }

    .app-header {
        padding: 20px 16px 16px;
        background: white;
    }

    .app-title {
        font-size: 24px;
        color: var(--md-text-primary);
    }

    .app-tagline {
        font-size: 13px;
        color: var(--md-text-secondary);
    }

    .controls-panel {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 16px;
        min-height: 56px; /* Mobile app bar height */
    }

    .control-group label {
        font-size: 12px;
    }

    .color-count-selector,
    .harmony-selector,
    .accessibility-selector {
        padding: 6px 10px;
        font-size: 13px;
    }

    .palette-container {
        flex-direction: column;
        min-height: 200px; /* Reduced to fit screen better */
    }

    .color-swatch {
        min-height: 45px; /* Compact minimum for 8 colors */
        flex: 1; /* Share available space equally */
    }

    .color-code {
        font-size: 10px; /* Compact mobile view - fits RGB/HSL */
        padding: 5px 8px; /* Compact padding */
    }

    .color-info {
        padding: 8px; /* Compact padding */
        display: flex; /* Horizontal side by side layout */
        flex-direction: row; /* Horizontal - code left, copy text right */
        align-items: center; /* Vertically centered */
        justify-content: center; /* Horizontally centered */
        gap: 8px; /* Space between hex code and copy text */
    }

    .format-toggle {
        font-size: 9px; /* Compact mobile view */
        margin-top: 0; /* Using gap instead */
        display: inline-flex;
        gap: 4px;
        align-items: center;
    }

    .copy-text::after {
        content: "•";
        margin-left: 4px;
    }

    .format-type {
        font-weight: 600;
    }

    .action-panel {
        flex-direction: column;
        gap: 8px;
        padding: 12px;
        flex-shrink: 0; /* Prevent action panel from shrinking */
    }

    .generate-btn {
        padding: 8px 20px;
        width: 100%;
        justify-content: center;
    }

    .secondary-btn {
        padding: 7px 19px;
        width: 100%;
        justify-content: center;
    }

    .lock-btn {
        width: 32px;
        height: 32px;
        top: 8px;
        right: 44px; /* Positioned left of contrast badge */
    }

    .lock-btn svg {
        width: 16px;
        height: 16px;
    }

    .refresh-btn {
        width: 32px;
        height: 32px;
        top: 8px;
        left: 8px; /* Left side on mobile */
    }

    .refresh-btn svg {
        width: 16px;
        height: 16px;
    }

    .contrast-badge {
        top: 8px; /* Aligned horizontally with lock button */
        right: 8px;
        width: 32px; /* Same size as lock button */
        height: 32px;
        border-radius: 50%; /* Circular like lock button */
        padding: 0; /* Remove padding for perfect circle */
        font-size: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Mobile: Adjust tooltip styling only */
    .contrast-tooltip {
        max-width: 320px;
        font-size: 12px;
        padding: 14px 16px;
    }

    .tooltip-title {
        font-size: 13px;
    }

    .tooltip-ratio {
        font-size: 12px;
    }

    .tooltip-list li {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .controls-panel {
        padding: 10px 12px;
    }

    .action-panel {
        padding: 12px;
    }

    .shortcut-hint {
        display: none;
    }

    .modal-content {
        max-width: 100%;
        max-height: 90vh;
    }

    .color-swatch {
        min-height: 60px;
    }
}

/* ========================================
   Tablet/Desktop Vertical Layout (769px+)
   ======================================== */

@media (min-width: 769px) {
    .color-info {
        display: flex;
        flex-direction: column-reverse; /* Vertical - copy text above, code below */
        align-items: center;
        justify-content: center;
        gap: 5px;
        padding: 10px 4px;
    }

    .color-code {
        font-size: 11px; /* Increased for better readability */
        padding: 3px 6px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%; /* Allow flex shrinking */
        flex-shrink: 1; /* Can shrink if needed */
    }

    .format-toggle {
        font-size: 8px; /* Increased for better readability */
        margin-top: 0;
        flex-shrink: 0; /* Don't shrink the label */
        display: flex;
        flex-direction: column; /* Stack vertically */
        align-items: center;
        gap: 2px;
    }

    .copy-text {
        display: block;
    }

    .copy-text::after {
        content: none; /* Remove bullet for vertical layout */
    }

    .format-type {
        display: block;
        font-weight: 600;
    }
}

/* ========================================
   Desktop Enhancements (1024px+)
   ======================================== */

@media (min-width: 1024px) {
    .palette-container {
        min-height: 500px;
    }

    .color-swatch {
        min-height: 500px;
    }

    .color-info {
        padding: 12px 6px;
        gap: 6px;
    }

    .color-code {
        font-size: 12px; /* Desktop - accommodates RGB/HSL */
        padding: 4px 7px;
    }

    .format-toggle {
        font-size: 9px; /* Larger for desktop readability */
    }
}

/* ========================================
   Footer
   ======================================== */

.site-footer {
    background: var(--md-surface);
    padding: 30px 20px;
    text-align: center;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    margin-top: 40px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-text {
    font-size: 14px;
    color: var(--md-text-secondary);
    margin-bottom: 12px;
}

.footer-links {
    font-size: 13px;
    color: var(--md-text-secondary);
}

.footer-link {
    color: var(--md-primary);
    text-decoration: none;
    transition: color var(--md-transition-standard);
}

.footer-link:hover {
    color: var(--md-primary-dark);
    text-decoration: underline;
}

.footer-separator {
    margin: 0 10px;
    color: var(--md-text-disabled);
}

@media (max-width: 600px) {
    .site-footer {
        padding: 20px 16px;
    }

    .footer-text {
        font-size: 13px;
    }

    .footer-links {
        font-size: 12px;
    }

    .footer-separator {
        margin: 0 6px;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .controls-panel,
    .action-panel,
    .shortcuts-info,
    .ad-container,
    .site-footer {
        display: none;
    }

    .palette-container {
        margin: 0;
    }
}