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

/* CSS Variables for Theme Support */
:root {
    --bg-primary: #fafafa;
    --bg-secondary: white;
    --bg-tertiary: #f5f5f5;
    --text-primary: #333;
    --text-secondary: #666;
    --text-tertiary: #999;
    --border-primary: #e0e0e0;
    --border-secondary: #ddd;
    --accent-primary: #007bff;
    --accent-primary-hover: #0056b3;
    --accent-secondary: #6c757d;
    --overlay-bg: rgba(0,0,0,0.5);
    --shadow: rgba(0,0,0,0.3);
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #404040;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;
    --border-primary: #404040;
    --border-secondary: #555;
    --accent-primary: #4dabf7;
    --accent-primary-hover: #339af0;
    --accent-secondary: #868e96;
    --overlay-bg: rgba(0,0,0,0.7);
    --shadow: rgba(0,0,0,0.5);
}

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

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100); /* Fallback for mobile browsers */
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 60px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.title {
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 500;
}

.note-id {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: 3px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.new-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.new-btn:hover {
    background: var(--accent-primary-hover);
}

.content {
    flex: 1;
    display: flex;
}

.note-area {
    flex: 1;
    border: none;
    outline: none;
    padding: 30px;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    resize: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.note-area::placeholder {
    color: var(--text-tertiary);
}

.id-input-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.id-input-dialog {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 20px var(--shadow);
    max-width: 400px;
    width: 90%;
    transition: background-color 0.3s ease;
}

.id-input-dialog h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.id-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-secondary);
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 15px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.dialog-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.dialog-btn.primary {
    background: var(--accent-primary);
    color: white;
}

.dialog-btn.primary:hover {
    background: var(--accent-primary-hover);
}

.dialog-btn.secondary {
    background: var(--accent-secondary);
    color: white;
}

.dialog-btn.secondary:hover {
    opacity: 0.9;
}

/* Theme Switch Styles */
.theme-switch {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 20px;
    padding: 4px;
    cursor: pointer;
    width: 44px;
    height: 24px;
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}

.theme-switch:hover {
    background: var(--border-primary);
}

.theme-switch::before {
    content: '';
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-primary);
    position: absolute;
    left: 4px;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.theme-switch.dark::before {
    transform: translateX(20px);
}

.hidden {
    display: none;
}

/* Mobile-First Responsive Design */

/* Base styles are already mobile-friendly, now add tablet and desktop improvements */

/* Small smartphones (portrait) */
@media screen and (max-width: 480px) {
    .header {
        padding: 12px 15px;
        min-height: 56px;
        flex-wrap: nowrap;
    }

    .title {
        font-size: 16px;
        font-weight: 600;
    }

    .header-right {
        gap: 8px;
        flex-shrink: 0;
    }

    .note-id {
        font-size: 10px;
        padding: 3px 6px;
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Make theme switch more touch-friendly */
    .theme-switch {
        width: 48px;
        height: 28px;
        padding: 6px;
        min-width: 48px;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .theme-switch::before {
        width: 18px;
        height: 18px;
        left: 6px;
    }

    .theme-switch.dark::before {
        transform: translateX(18px);
    }

    /* Touch-friendly buttons */
    .new-btn {
        padding: 10px 14px;
        font-size: 13px;
        min-height: 44px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Optimize text area for mobile */
    .note-area {
        padding: 20px 15px;
        font-size: 16px; /* Prevents zoom on iOS */
        line-height: 1.5;
        -webkit-appearance: none;
        border-radius: 0;
    }

    /* Mobile-optimized modal */
    .id-input-overlay {
        padding: 20px 15px;
        align-items: flex-start;
        padding-top: 25vh;
    }

    .id-input-dialog {
        padding: 24px 20px;
        margin: 0;
        border-radius: 12px;
        width: 100%;
        max-width: 320px;
    }

    .id-input-dialog h3 {
        font-size: 18px;
        margin-bottom: 16px;
    }

    .id-input {
        padding: 14px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 8px;
        margin-bottom: 20px;
        -webkit-appearance: none;
    }

    .dialog-buttons {
        gap: 12px;
        flex-direction: row;
    }

    .dialog-btn {
        flex: 1;
        padding: 12px 16px;
        font-size: 14px;
        font-weight: 500;
        min-height: 44px;
        border-radius: 8px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
}

/* Larger smartphones and small tablets (landscape phones) */
@media screen and (min-width: 481px) and (max-width: 768px) {
    .header {
        padding: 15px 20px;
    }

    .title {
        font-size: 18px;
    }

    .note-area {
        padding: 25px 20px;
        font-size: 16px;
    }

    .id-input-dialog {
        max-width: 400px;
        padding: 28px 24px;
    }

    .theme-switch {
        width: 46px;
        height: 26px;
    }

    .theme-switch::before {
        width: 17px;
        height: 17px;
        left: 5px;
    }

    .theme-switch.dark::before {
        transform: translateX(19px);
    }
}

/* Tablets and small desktops */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .header {
        padding: 16px 24px;
        min-height: 64px;
    }

    .title {
        font-size: 20px;
    }

    .note-area {
        padding: 32px 28px;
        font-size: 17px;
    }

    .new-btn {
        padding: 10px 18px;
        font-size: 15px;
    }
}

/* Large screens and desktops */
@media screen and (min-width: 1025px) {
    .header {
        padding: 18px 32px;
        min-height: 68px;
    }

    .title {
        font-size: 22px;
    }

    .note-area {
        padding: 40px 36px;
        font-size: 18px;
    }

    .id-input-dialog {
        max-width: 480px;
        padding: 36px 32px;
    }
}

/* Touch-specific improvements */
@media (hover: none) and (pointer: coarse) {
    /* This targets touch devices specifically */

    .new-btn:hover,
    .dialog-btn:hover,
    .theme-switch:hover {
        /* Remove hover effects on touch devices */
        background: var(--accent-primary);
        opacity: 1;
    }

    .dialog-btn.secondary:hover {
        background: var(--accent-secondary);
        opacity: 1;
    }

    .theme-switch:hover {
        background: var(--bg-tertiary);
    }

    /* Add active states for touch feedback */
    .new-btn:active {
        background: var(--accent-primary-hover);
        transform: scale(0.98);
    }

    .dialog-btn:active {
        transform: scale(0.98);
    }

    .theme-switch:active {
        transform: scale(0.95);
    }
}

/* High-DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .theme-switch::before {
        box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    }

    .id-input-dialog {
        box-shadow: 0 8px 32px var(--shadow);
    }
}

/* Landscape orientation optimizations */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .header {
        min-height: 48px;
        padding: 10px 15px;
    }

    .title {
        font-size: 14px;
    }

    .new-btn {
        padding: 8px 12px;
        font-size: 12px;
        min-height: 36px;
    }

    .theme-switch {
        width: 40px;
        height: 22px;
        min-height: 36px;
    }

    .theme-switch::before {
        width: 14px;
        height: 14px;
        left: 4px;
    }

    .theme-switch.dark::before {
        transform: translateX(16px);
    }

    .note-area {
        padding: 15px;
        font-size: 15px;
    }

    .id-input-overlay {
        padding-top: 10vh;
    }

    .id-input-dialog {
        padding: 20px;
        max-width: 400px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .theme-switch::before {
        transition: none;
    }

    body {
        transition: none;
    }
}

/* Dark theme specific mobile adjustments */
[data-theme="dark"] {
    /* Better contrast for mobile screens */
    --text-primary: #f0f0f0;
    --text-secondary: #c0c0c0;
    --border-primary: #4a4a4a;
}

@media screen and (max-width: 480px) {
    [data-theme="dark"] {
        --bg-primary: #0d1117;
        --bg-secondary: #1c2128;
        --bg-tertiary: #2d333b;
    }
}