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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

/* First Time Setup Screen */
.first-time-setup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 20px;
}

.first-time-setup.hidden {
    display: none;
}

.setup-container {
    background: rgba(255,255,255,0.95);
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    max-width: 500px;
    width: 100%;
    animation: slideInUp 0.6s ease-out;
}

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

.setup-header h1 {
    font-size: 32px;
    color: #2c3e50;
    margin-bottom: 10px;
    font-weight: 300;
}

.setup-header p {
    font-size: 18px;
    color: #7f8c8d;
    margin-bottom: 40px;
}

.name-input-section label {
    display: block;
    font-size: 20px;
    color: #2c3e50;
    margin-bottom: 15px;
    font-weight: 500;
}

.name-input-section input {
    width: 100%;
    padding: 15px 20px;
    font-size: 18px;
    border: 2px solid #e0e6ed;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 25px;
    transition: all 0.3s ease;
    background: #ffffff;
}

.name-input-section input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.name-input-section button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 18px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    letter-spacing: 1px;
}

.name-input-section button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.name-input-section button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Cover Selection Screen */
.cover-selection {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.cover-selection.hidden {
    display: none;
}

.selection-header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
}

.selection-header h2 {
    font-size: 28px;
    margin-bottom: 10px;
    font-weight: 300;
}

.selection-header p {
    font-size: 16px;
    opacity: 0.8;
}

.covers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    max-width: 400px;
    width: 100%;
}

.cover-option {
    cursor: pointer;
    transition: transform 0.3s ease;
}

.cover-option:hover {
    transform: scale(1.05);
}

.cover-preview {
    width: 160px;
    height: 200px;
    background-size: cover;
    background-position: center;
    background-color: #8b4513;
    border-radius: 10px;
    position: relative;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    border: 3px solid rgba(255,255,255,0.2);
}

.cover-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: white;
    padding: 15px 10px 10px;
    border-radius: 0 0 7px 7px;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
}

/* Closed Notebook Cover */
.notebook-cover {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    z-index: 100;
    background: #2c3e50;
}

.notebook-cover.hidden {
    display: none;
}

.cover-image {
    flex: 1;
    background-size: cover;
    background-position: center;
    background-color: #8b4513;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    margin: 10px;
    margin-right: 5px;
    border-radius: 15px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
    border: 3px solid rgba(255,255,255,0.1);
}

.cover-title {
    text-align: center;
    color: white;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.7);
    padding: 20px;
    background: rgba(0,0,0,0.3);
    border-radius: 15px;
    backdrop-filter: blur(5px);
}

.cover-title h1 {
    font-size: 32px;
    margin-bottom: 10px;
    font-weight: 300;
    letter-spacing: 3px;
}

.cover-subtitle {
    font-size: 14px;
    opacity: 0.9;
    letter-spacing: 1px;
}

.alphabet-tabs-cover {
    width: 60px;
    background: linear-gradient(180deg, #8b4513 0%, #5d2f0f 100%);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 10px 5px;
    margin: 10px 10px 10px 5px;
    border-radius: 0 15px 15px 0;
    box-shadow: -5px 0 15px rgba(0,0,0,0.3);
}

.alphabet-tabs-cover .alpha-tab {
    width: 50px;
    height: 25px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    color: #f4d03f;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1px 0;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    font-size: 11px;
    border-radius: 5px;
}

.alphabet-tabs-cover .alpha-tab:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.05);
    color: white;
}

.cover-settings {
    position: absolute;
    bottom: 20px;
    left: 20px;
}

.cover-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

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

/* Open Notebook App */
.app-container {
    display: none;
    height: 100vh;
    background: #fff;
    margin: 10px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
}

.app-container.active {
    display: flex;
}

.notebook {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fefefe;
    position: relative;
}

/* REMOVED: Spiral rings and red line */
.notebook::before {
    display: none;
}

.notebook::after {
    display: none;
}

.spiral-rings {
    display: none;
}

.spiral-ring {
    display: none;
}

.header {
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
}

.quit-btn {
    background: rgba(255,0,0,0.2);
    border: 1px solid rgba(255,0,0,0.3);
    color: white;
    padding: 8px 12px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.quit-btn:hover {
    background: rgba(255,0,0,0.4);
    transform: scale(1.1);
}

.header-controls {
    display: flex;
    gap: 10px;
    position: relative;
}

.settings-btn, .close-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 8px 12px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.tools-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    transition: all 0.3s ease;
    min-width: 50px;
}

.settings-btn:hover, .tools-btn:hover, .close-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

.current-section {
    display: none;
}

.save-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 5px 10px;
    background: #28a745;
    color: white;
    border-radius: 15px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.save-indicator.show {
    opacity: 1;
}

.note-area {
    flex: 1;
    padding: 20px 20px 20px 5px;
    overflow-y: auto;
    background: 
        radial-gradient(circle at 20% 80%, rgba(178, 159, 137, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(178, 159, 137, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(139, 125, 107, 0.05) 0%, transparent 50%),
        linear-gradient(135deg, #f7f4f0 0%, #f2ede6 100%);
    position: relative;
    background-size: 
        300px 300px,
        200px 200px,
        400px 400px,
        100% 100%;
}

/* Rich Text Editor */
.rich-editor {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-size: 18px;
    line-height: 1.6;
    font-family: inherit;
    color: #333;
    min-height: 400px;
    margin-top: 40px;
    padding: 20px 0 20px 5px;
    user-select: text;
}

.rich-editor:empty::before {
    content: 'Start writing your notes here... Select text and use the formatting toolbar below to style it!';
    color: #999;
    font-style: italic;
    pointer-events: none;
}

.rich-editor:focus {
    outline: none;
}

/* Tools Dropdown Menu */
.tools-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 200px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 5px;
}

.tools-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.tools-dropdown-content {
    padding: 15px;
}

.tools-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 10px;
}

.tools-divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, transparent, #e9ecef, transparent);
    margin: 10px 0;
}

/* Font Size Section in Dropdown */
.font-size-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.font-size-display {
    font-size: 14px;
    color: #333;
    font-weight: bold;
    min-width: 50px;
    text-align: center;
    background: #f8f9fa;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.font-size-arrows {
    display: flex;
    gap: 6px;
}

.arrow-btn {
    width: 45px;
    height: 40px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.arrow-btn:hover {
    background: #667eea;
    color: white;
    transform: scale(1.05);
}

.reset-btn {
    width: 96px;
    height: 35px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-top: 4px;
}

.reset-btn:hover {
    background: #667eea;
    color: white;
    transform: scale(1.02);
}

/* Format Section in Dropdown */
.format-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.format-buttons {
    display: flex;
    gap: 6px;
}

.format-btn {
    width: 50px;
    height: 45px;
    border: 2px solid #28a745;
    background: white;
    color: #28a745;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.format-btn:hover {
    background: #28a745;
    color: white;
    transform: translateY(-1px);
}

.format-btn.active {
    background: #28a745;
    color: white;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.3);
}

/* Color Section in Dropdown */
.color-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 6px;
    justify-items: center;
    align-items: center;
}

.color-btn {
    width: 32px;
    height: 32px;
    border: 2px solid #666;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.color-btn:hover {
    transform: scale(1.15);
    border-color: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Action Section in Dropdown */
.action-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.action-buttons {
    display: flex;
    gap: 6px;
}

.action-btn {
    width: 50px;
    height: 45px;
    border: 2px solid #dc2626;
    background: white;
    color: #dc2626;
    cursor: pointer;
    font-size: 18px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: #dc2626;
    color: white;
    transform: translateY(-1px);
}

/* Settings Menu */
.settings-menu {
    position: absolute;
    top: 70px;
    right: 15px;
    width: 250px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.settings-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.settings-menu-content {
    padding: 0;
}

.settings-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px 10px 0 0;
}

.settings-menu-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

.close-settings-menu {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.close-settings-menu:hover {
    background: rgba(255,255,255,0.2);
}

.settings-menu-options {
    padding: 10px 0;
}

.settings-option {
    width: 100%;
    padding: 12px 20px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-option:hover {
    background: #f8f9fa;
}

.note-divider {
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #667eea, transparent);
    margin: 20px 0;
    position: relative;
}

.note-divider::before {
    content: '✦';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #f7f4f0;
    color: #667eea;
    padding: 0 10px;
    font-size: 14px;
}

.alphabet-tabs {
    width: 60px;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 10px 5px;
}

.alpha-tab {
    width: 50px;
    height: 35px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2px 0;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    font-size: 12px;
    border-radius: 5px;
}

.alpha-tab:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.05);
}

.alpha-tab.active {
    background: rgba(255,255,255,0.3);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.install-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #667eea;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    z-index: 1000;
    display: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .app-container {
        margin: 5px;
        border-radius: 10px;
    }
    
    .alphabet-tabs, .alphabet-tabs-cover {
        width: 50px;
    }
    
    .alpha-tab {
        width: 40px;
        height: 30px;
        font-size: 10px;
    }
    
    .note-area {
        padding-left: 5px;
        padding-bottom: 20px;
    }
    
    .header {
        padding: 10px 15px;
        min-height: 50px;
    }
    
    .quit-btn, .settings-btn, .close-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .tools-btn {
        padding: 6px 10px;
        font-size: 10px;
        min-width: 45px;
    }
    
    .tools-dropdown {
        top: 100%;
        right: 0;
        width: 180px;
        max-height: 250px;
        margin-top: 5px;
    }
    
    .arrow-btn {
        width: 40px;
        height: 35px;
        font-size: 14px;
    }
    
    .reset-btn {
        width: 86px;
        height: 30px;
        font-size: 12px;
    }
    
    .format-btn {
        width: 45px;
        height: 40px;
        font-size: 16px;
    }
    
    .color-btn {
        width: 28px;
        height: 28px;
    }
    
    .action-btn {
        width: 45px;
        height: 40px;
        font-size: 16px;
    }
}

/* Cover Theme Colors */
.cover-male-1 .alphabet-tabs-cover {
    background: linear-gradient(180deg, #8b4513 0%, #5d2f0f 100%);
}

.cover-male-2 .alphabet-tabs-cover {
    background: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%);
}

.cover-female-1 .alphabet-tabs-cover {
    background: linear-gradient(180deg, #d4a574 0%, #a67c52 100%);
}

.cover-female-2 .alphabet-tabs-cover {
    background: linear-gradient(180deg, #8e44ad 0%, #6c3483 100%);
}