/* Reset y variables CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Apple-inspired Color System */
    --primary-color: #007AFF;
    --primary-hover: #0056CC;
    --primary-light: #E3F2FD;
    --secondary-color: #5856D6;
    --accent-color: #FF3B30;
    --success-color: #34C759;
    --warning-color: #FF9500;
    --info-color: #5AC8FA;
    
    /* Background System */
    --background-primary: #FFFFFF;
    --background-secondary: #F2F2F7;
    --background-tertiary: #FFFFFF;
    --background-grouped: #F2F2F7;
    --background-elevated: #FFFFFF;
    
    /* Text System */
    --text-primary: #000000;
    --text-secondary: #3C3C43;
    --text-tertiary: #3C3C43;
    --text-quaternary: #3C3C43;
    --text-placeholder: #3C3C43;
    
    /* Separator System */
    --separator: #3C3C43;
    --separator-opaque: #C6C6C8;
    
    /* Fill System */
    --fill-primary: #787880;
    --fill-secondary: #787880;
    --fill-tertiary: #787880;
    --fill-quaternary: #787880;
    
    /* Shadow System */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 25px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 16px 40px rgba(0, 0, 0, 0.2);
    --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.25);
    
    /* Border Radius System */
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-full: 9999px;
    
    /* Animation System */
    --transition-fast: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-normal: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-slow: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-bounce: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Typography Scale */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    --font-size-5xl: 3rem;
    
    /* Spacing Scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;
    
    /* Legacy compatibility */
    --background-color: var(--background-secondary);
    --card-background: var(--background-primary);
    --text-primary: var(--text-primary);
    --text-secondary: var(--text-secondary);
    --border-color: var(--separator-opaque);
    --shadow: var(--shadow-sm);
    --shadow-lg: var(--shadow-lg);
    --border-radius: var(--radius-md);
    --transition: var(--transition-normal);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--background-secondary);
    color: var(--text-primary);
    line-height: 1.47;
    font-size: var(--font-size-base);
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-6);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
}

/* Apple-style Layout System */
.app-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-6);
    min-height: calc(100vh - var(--space-12));
}

.app-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    flex: 1;
}

.app-section {
    background: var(--background-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--separator-opaque);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Header */
/* Apple-style Header */
.header {
    text-align: center;
    padding: var(--space-8) 0;
    background: linear-gradient(135deg, var(--background-primary) 0%, var(--background-secondary) 100%);
    border-radius: var(--radius-2xl);
    margin-bottom: var(--space-8);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.05) 0%, rgba(88, 86, 214, 0.05) 100%);
    pointer-events: none;
}

.header h1 {
    font-size: var(--font-size-5xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
    letter-spacing: -0.02em;
    line-height: 1.1;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
}

.header p {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    font-weight: 400;
    line-height: 1.5;
    position: relative;
    z-index: 1;
}

/* Header with icon */
.header-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-6);
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.header-icon i {
    font-size: 28px;
    color: white;
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Buttons */
/* Apple-style Button System */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    border: none;
    border-radius: var(--radius-full);
    font-size: var(--font-size-base);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    min-height: 44px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    opacity: 0;
    transition: var(--transition-fast);
    pointer-events: none;
}

.btn:hover::before {
    opacity: 1;
}

.btn:active {
    transform: scale(0.98);
}

.btn i {
    font-size: 1em;
    line-height: 1;
}

/* Primary Button */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Secondary Button */
.btn-secondary {
    background: var(--background-primary);
    color: var(--text-primary);
    border: 1px solid var(--separator-opaque);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--background-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Success Button */
.btn-success {
    background: linear-gradient(135deg, var(--success-color), #30D158);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Warning Button */
.btn-warning {
    background: linear-gradient(135deg, var(--warning-color), #FF9F0A);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Danger Button */
.btn-danger {
    background: linear-gradient(135deg, var(--accent-color), #FF453A);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Outline Button */
.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    box-shadow: none;
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Button States */
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn:disabled::before {
    display: none;
}

/* Button Sizes */
.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    min-height: 36px;
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-size-lg);
    min-height: 52px;
}

/* Stats */
.stats {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
    background: var(--card-background);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    min-width: 120px;
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Containers */
.folders-container,
.docks-container,
.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: var(--border-color);
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* Apple-style Cards */
.card,
.folder-card,
.dock-card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition-normal);
    position: relative;
    cursor: pointer;
}

.card::before,
.folder-card::before,
.dock-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    opacity: 0;
    transition: var(--transition-normal);
    pointer-events: none;
}

.card:hover,
.folder-card:hover,
.dock-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-xl);
    border-color: rgba(0, 122, 255, 0.3);
}

.card:hover::before,
.folder-card:hover::before,
.dock-card:hover::before {
    opacity: 1;
}

.card:active,
.folder-card:active,
.dock-card:active {
    transform: translateY(-2px) scale(1.01);
    transition: var(--transition-fast);
}

.card-header,
.folder-header,
.dock-header {
    padding: 1.5rem 1.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.card-number,
.dock-number {
    background: var(--primary-color);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.folder-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.card-actions,
.folder-actions,
.dock-actions {
    display: flex;
    gap: 0.5rem;
}

.card-content,
.folder-content,
.dock-content {
    padding: 1.5rem;
}

.card-question {
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.card-answer {
    color: var(--text-secondary);
    line-height: 1.6;
    background: var(--background-color);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

/* Folder specific styles */
.folder-name,
.dock-name {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.folder-description,
.dock-description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.folder-stats,
.dock-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.folder-stat,
.dock-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.folder-footer,
.dock-footer {
    padding: 0 1.5rem 1.5rem;
}

/* Card specific styles */
.card-stats {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.card-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.difficulty-easy {
    color: var(--success-color);
}

.difficulty-medium {
    color: var(--warning-color);
}

.difficulty-hard {
    color: var(--danger-color);
}

/* Study Mode Selection */
.study-mode-selection {
    max-width: 800px;
    margin: 0 auto 2rem;
    text-align: center;
}

.study-mode-selection h3 {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.study-modes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.study-mode-option {
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.study-mode-option:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.study-mode-option i {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.study-mode-option h4 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.study-mode-option p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

/* Study Mode */
.study-mode {
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
}

.study-mode-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.study-mode-info h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.study-timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--warning-color);
    font-weight: 600;
    font-size: 1.1rem;
}

.study-score {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.1rem;
}

.study-bottom-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.study-card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
    overflow: hidden;
}

.study-content {
    padding: 3rem 2rem;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-side {
    width: 100%;
}

.card-side h3 {
    color: var(--text-secondary);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.card-side p {
    font-size: 1.25rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.study-controls {
    padding: 1.5rem;
    background: var(--background-color);
    border-top: 1px solid var(--border-color);
}

.study-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Exam Mode Styles */
.exam-answer-input,
.memory-answer-input {
    margin-top: 1.5rem;
}

.exam-answer-input textarea,
.memory-answer-input textarea {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
}

.exam-answer-input textarea:focus,
.memory-answer-input textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Multiple Choice Styles */
.multiple-choice-options {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.multiple-choice-option {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: var(--background-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.multiple-choice-option:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.multiple-choice-option.selected {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.multiple-choice-option.correct {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
}

.multiple-choice-option.incorrect {
    border-color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
}

.multiple-choice-option input[type="radio"] {
    margin-right: 0.75rem;
    transform: scale(1.2);
}

.multiple-choice-option label {
    cursor: pointer;
    flex: 1;
    margin: 0;
    font-size: 1rem;
    line-height: 1.4;
}

/* True/False Styles */
.true-false-options {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.true-false-options .btn {
    min-width: 150px;
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.true-false-options .btn.selected {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

/* Answer Feedback */
.answer-feedback {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    font-weight: 500;
}

.answer-feedback.correct {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.answer-feedback.incorrect {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.answer-feedback.partial {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border: 1px solid var(--warning-color);
}

/* Loading for AI Generation */
.ai-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    color: var(--text-secondary);
}

.ai-loading .spinner {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

/* Gemini Modal Styles */
.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.modal-body small {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.modal-body small a {
    color: var(--primary-color);
    text-decoration: none;
}

.modal-body small a:hover {
    text-decoration: underline;
}

.study-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    justify-content: center;
}

.progress-bar {
    flex: 1;
    max-width: 300px;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
    width: 0%;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
}

.close-btn:hover {
    background: var(--background-color);
    color: var(--text-primary);
}

/* Bulk Import Styles */
.bulk-import-preview {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--background-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.bulk-import-preview h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.preview-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
}

.preview-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    transition: var(--transition);
}

.preview-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

.preview-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.preview-card-number {
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    min-width: 24px;
    text-align: center;
}

.preview-card-type {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-card-content p {
    margin: 0.5rem 0;
    line-height: 1.4;
    font-size: 0.9rem;
}

.preview-card-content p:first-child {
    margin-top: 0;
}

.preview-card-content p:last-child {
    margin-bottom: 0;
}

.preview-card-content strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* Bulk Import Textarea */
#bulkImportText {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 200px;
    max-height: 400px;
}

#bulkImportText::placeholder {
    color: var(--text-secondary);
    font-style: italic;
}

/* True/False Button Selection Styles */
.true-false-options .btn.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
    transform: scale(1.05);
}

.true-false-options .btn.selected:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

.true-false-options .btn:not(.selected) {
    background: var(--card-background);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.true-false-options .btn:not(.selected):hover {
    background: var(--background-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Form */
form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
}

.form-group input {
    height: 48px;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Color Picker */
.color-picker {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.color-picker input[type="radio"] {
    display: none;
}

.color-picker label {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
}

.color-picker input[type="radio"]:checked + label {
    border-color: var(--text-primary);
    transform: scale(1.1);
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Loading */
.loading {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
}

.loading.show {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Breadcrumb Navigation */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.breadcrumb-item {
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.breadcrumb-item:hover {
    color: var(--primary-color);
}

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 500;
}

.breadcrumb-separator {
    color: var(--text-secondary);
}

/* ===== RESPONSIVE DESIGN ===== */

/* Extra Large Devices (1400px and up) */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
    
    .folders-container,
    .docks-container,
    .cards-container {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
        gap: 2rem;
    }
    
    .header h1 {
        font-size: 3rem;
    }
    
    .study-card {
        max-width: 700px;
    }
}

/* Large Devices (1200px and up) */
@media (min-width: 1200px) and (max-width: 1399px) {
    .container {
        max-width: 1140px;
    }
    
    .folders-container,
    .docks-container,
    .cards-container {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 1.75rem;
    }
}

/* Medium Devices (992px and up) */
@media (min-width: 992px) and (max-width: 1199px) {
    .container {
        max-width: 960px;
    }
    
    .folders-container,
    .docks-container,
    .cards-container {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 1.5rem;
    }
    
    .header h1 {
        font-size: 2.75rem;
    }
}

/* Small Devices (768px and up) */
@media (min-width: 768px) and (max-width: 991px) {
    .container {
        max-width: 720px;
        padding: 1.5rem;
    }
    
    .header h1 {
        font-size: 2.5rem;
    }
    
    .controls {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .btn {
        flex: 1;
        min-width: 200px;
    }
    
    .stats {
        gap: 1.25rem;
    }
    
    .folders-container,
    .docks-container,
    .cards-container {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.25rem;
    }
    
    .study-actions {
        gap: 0.75rem;
    }
    
    .study-actions .btn {
        flex: 1;
        min-width: 120px;
    }
    
    .modal-content {
        margin: 1.5rem;
        max-width: 90vw;
    }
    
    .breadcrumb {
        padding: 0.75rem;
        gap: 0.5rem;
    }
}

/* Mobile Devices (576px and up) */
@media (min-width: 576px) and (max-width: 767px) {
    .container {
        padding: 1rem;
    }
    
    .header h1 {
        font-size: 2.25rem;
    }
    
    .header p {
        font-size: 1rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .btn {
        width: 100%;
        padding: 1rem 1.5rem;
        font-size: 1rem;
        justify-content: center;
    }
    
    .stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
    
    .stat-item {
        padding: 1.25rem;
        min-width: auto;
    }
    
    .stat-number {
        font-size: 1.75rem;
    }
    
    .folders-container,
    .docks-container,
    .cards-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .card-header,
    .folder-header,
    .dock-header {
        padding: 1.25rem 1.25rem 0;
    }
    
    .card-content,
    .folder-content,
    .dock-content {
        padding: 1.25rem;
    }
    
    .folder-footer,
    .dock-footer {
        padding: 0 1.25rem 1.25rem;
    }
    
    .study-mode {
        padding: 0 1rem;
    }
    
    .study-content {
        padding: 2.5rem 1.5rem;
        min-height: 280px;
    }
    
    .study-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .study-actions .btn {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .form-actions .btn {
        width: 100%;
        padding: 1rem;
    }
    
    .modal-content {
        margin: 1rem;
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 1.25rem;
    }
    
    .modal-header h2 {
        font-size: 1.375rem;
    }
    
    form {
        padding: 1.25rem;
    }
    
    .form-group input,
    .form-group textarea {
        padding: 1rem;
        font-size: 1rem;
    }
    
    .form-group input {
        height: 52px;
    }
    
    .form-group textarea {
        min-height: 120px;
    }
    
    .breadcrumb {
        flex-wrap: wrap;
        gap: 0.375rem;
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .folder-stats,
    .dock-stats {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .folder-stat,
    .dock-stat {
        font-size: 0.8rem;
    }
    
    .color-picker {
        justify-content: center;
        gap: 0.75rem;
    }
    
    .color-picker label {
        width: 44px;
        height: 44px;
    }
}

/* Extra Small Devices (up to 575px) */
@media (max-width: 575px) {
    .container {
        padding: 0.75rem;
    }
    
    .header {
        margin-bottom: 1.5rem;
    }
    
    .header h1 {
        font-size: 1.875rem;
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .header p {
        font-size: 0.95rem;
        margin-top: 0.5rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        margin-bottom: 1.5rem;
    }
    
    .btn {
        width: 100%;
        padding: 0.875rem 1.25rem;
        font-size: 0.95rem;
        justify-content: center;
        border-radius: 10px;
    }
    
    .btn i {
        font-size: 0.9rem;
    }
    
    .stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }
    
    .stat-item {
        padding: 1rem;
        min-width: auto;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    .folders-container,
    .docks-container,
    .cards-container {
        grid-template-columns: 1fr;
        gap: 0.875rem;
        margin-bottom: 1.5rem;
    }
    
    .card-header,
    .folder-header,
    .dock-header {
        padding: 1rem 1rem 0;
    }
    
    .card-number,
    .dock-number {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }
    
    .folder-icon {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
    
    .card-actions,
    .folder-actions,
    .dock-actions {
        gap: 0.375rem;
    }
    
    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .card-content,
    .folder-content,
    .dock-content {
        padding: 1rem;
    }
    
    .folder-name,
    .dock-name {
        font-size: 1rem;
        margin-bottom: 0.375rem;
    }
    
    .folder-description,
    .dock-description {
        font-size: 0.9rem;
        margin-bottom: 0.875rem;
    }
    
    .card-question {
        font-size: 0.95rem;
        margin-bottom: 0.875rem;
    }
    
    .card-answer {
        font-size: 0.9rem;
        padding: 0.875rem;
    }
    
    .folder-footer,
    .dock-footer {
        padding: 0 1rem 1rem;
    }
    
    .folder-stats,
    .dock-stats {
        flex-direction: column;
        gap: 0.5rem;
        margin-bottom: 0.875rem;
    }
    
    .folder-stat,
    .dock-stat {
        font-size: 0.75rem;
    }
    
    .card-stats {
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 0.875rem;
    }
    
    .card-stat {
        font-size: 0.75rem;
    }
    
    .study-mode {
        padding: 0 0.5rem;
    }
    
    .study-card {
        margin-bottom: 1.5rem;
    }
    
    .study-content {
        padding: 2rem 1rem;
        min-height: 250px;
    }
    
    .card-side h3 {
        font-size: 0.9rem;
        margin-bottom: 0.875rem;
    }
    
    .card-side p {
        font-size: 1rem;
        line-height: 1.5;
    }
    
    .study-controls {
        padding: 1.25rem;
    }
    
    .study-actions {
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 0.875rem;
    }
    
    .study-actions .btn {
        width: 100%;
        padding: 0.875rem;
        font-size: 0.95rem;
    }
    
    .study-progress {
        margin-bottom: 1.5rem;
        gap: 0.75rem;
    }
    
    .progress-bar {
        max-width: 250px;
        height: 6px;
    }
    
    .study-counter {
        font-size: 0.9rem;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1.5rem;
    }
    
    .form-actions .btn {
        width: 100%;
        padding: 0.875rem;
        font-size: 0.95rem;
    }
    
    .modal {
        padding: 0.5rem;
    }
    
    .modal-content {
        margin: 0;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .modal-header {
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
    }
    
    .modal-header h2 {
        font-size: 1.25rem;
    }
    
    .close-btn {
        font-size: 1.25rem;
        padding: 0.375rem;
    }
    
    form {
        padding: 1rem;
    }
    
    .form-group {
        margin-bottom: 1.25rem;
    }
    
    .form-group label {
        font-size: 0.9rem;
        margin-bottom: 0.375rem;
    }
    
    .form-group input,
    .form-group textarea {
        padding: 0.875rem;
        font-size: 0.95rem;
        border-radius: 8px;
    }
    
    .form-group input {
        height: 48px;
    }
    
    .form-group textarea {
        min-height: 100px;
    }
    
    .breadcrumb {
        flex-wrap: wrap;
        gap: 0.25rem;
        padding: 0.75rem;
        font-size: 0.85rem;
        margin-bottom: 1.5rem;
    }
    
    .breadcrumb-item {
        font-size: 0.85rem;
    }
    
    .breadcrumb-separator {
        font-size: 0.8rem;
    }
    
    .color-picker {
        justify-content: center;
        gap: 0.5rem;
    }
    
    .color-picker label {
        width: 40px;
        height: 40px;
    }
    
    .empty-state {
        padding: 3rem 1rem;
    }
    
    .empty-state i {
        font-size: 3rem;
        margin-bottom: 0.875rem;
    }
    
    .empty-state h3 {
        font-size: 1.25rem;
        margin-bottom: 0.375rem;
    }
    
    .empty-state p {
        font-size: 0.9rem;
    }
    
    .loading {
        gap: 0.75rem;
    }
    
    .spinner {
        width: 32px;
        height: 32px;
        border-width: 3px;
    }
    
    .loading p {
        font-size: 0.9rem;
    }
}

/* Landscape Mobile Devices */
@media (max-width: 767px) and (orientation: landscape) {
    .header {
        margin-bottom: 1rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .header p {
        font-size: 0.9rem;
    }
    
    .controls {
        flex-direction: row;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .btn {
        flex: 1;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .stats {
        gap: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .stat-item {
        padding: 0.75rem;
    }
    
    .stat-number {
        font-size: 1.25rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .study-content {
        padding: 1.5rem 1rem;
        min-height: 200px;
    }
    
    .study-actions {
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .study-actions .btn {
        flex: 1;
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .modal-content {
        max-height: 90vh;
    }
    
    .form-actions {
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .form-actions .btn {
        flex: 1;
        padding: 0.75rem;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        padding: 0.875rem 1.25rem;
    }
    
    .btn-sm {
        min-height: 36px;
        padding: 0.5rem 0.875rem;
    }
    
    .card-actions,
    .folder-actions,
    .dock-actions {
        gap: 0.75rem;
    }
    
    .color-picker label {
        min-width: 44px;
        min-height: 44px;
    }
    
    .close-btn {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .breadcrumb-item {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 0.5rem;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .btn,
    .card,
    .folder-card,
    .dock-card {
        border: 0.5px solid transparent;
    }
    
    .modal-content {
        border: 0.5px solid var(--border-color);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .card,
    .folder-card,
    .dock-card {
        animation: none;
    }
    
    .btn:hover {
        transform: none;
    }
    
    .card:hover,
    .folder-card:hover,
    .dock-card:hover {
        transform: none;
    }
    
    .color-picker input[type="radio"]:checked + label {
        transform: none;
    }
}

/* Print Styles */
@media print {
    .controls,
    .study-mode,
    .modal,
    .loading {
        display: none !important;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    .card,
    .folder-card,
    .dock-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
        margin-bottom: 1rem;
    }
    
    .header h1 {
        color: #000;
    }
    
    .breadcrumb {
        background: none;
        box-shadow: none;
        border: none;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card,
.folder-card,
.dock-card {
    animation: fadeIn 0.3s ease;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.btn:focus,
.close-btn:focus,
textarea:focus,
input:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Touch-friendly focus styles */
@media (hover: none) and (pointer: coarse) {
    .btn:focus,
    .close-btn:focus,
    .color-picker label:focus {
        outline: 3px solid var(--primary-color);
        outline-offset: 3px;
    }
}

/* Improved touch targets */
.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Swipe gestures support */
.swipe-container {
    touch-action: pan-x;
    overflow-x: hidden;
}

/* Improved scrolling on mobile */
@media (max-width: 767px) {
    body {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
    }
    
    .modal-content {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-secondary: #000000;
    }
}

/* Apple-style Animations and Micro-interactions */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -8px, 0);
    }
    70% {
        transform: translate3d(0, -4px, 0);
    }
    90% {
        transform: translate3d(0, -2px, 0);
    }
}

/* Animation Classes */
.animate-fade-in-up {
    animation: fadeInUp 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.animate-fade-in-scale {
    animation: fadeInScale 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.animate-slide-in-right {
    animation: slideInRight 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-bounce {
    animation: bounce 1s infinite;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200px 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text:last-child {
    margin-bottom: 0;
    width: 60%;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-button {
    height: 44px;
    width: 120px;
    border-radius: var(--radius-full);
}

/* Loading States */
.loading-shimmer {
    position: relative;
    overflow: hidden;
}

.loading-shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 1.5s infinite;
}

/* Hover Effects */
.hover-lift {
    transition: var(--transition-normal);
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.hover-glow {
    transition: var(--transition-normal);
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(0, 122, 255, 0.3);
}

.hover-scale {
    transition: var(--transition-normal);
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* Focus States */
.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.3);
}

/* Smooth Transitions */
.transition-all {
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.transition-colors {
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.transition-transform {
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Stagger Animation */
.stagger-item {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.1s; }
.stagger-item:nth-child(2) { animation-delay: 0.2s; }
.stagger-item:nth-child(3) { animation-delay: 0.3s; }
.stagger-item:nth-child(4) { animation-delay: 0.4s; }
.stagger-item:nth-child(5) { animation-delay: 0.5s; }
.stagger-item:nth-child(6) { animation-delay: 0.6s; }
