/* GitHub-inspired CSS Variables */
:root {
    /* Colors - GitHub Dark Theme */
    --bg-primary: #0d1118;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #30363d;
    --bg-active: #383e48;
    
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #656d76;
    
    --border-default: #30363d;
    --border-muted: #21262d;
    
    --accent-primary: #238636;
    --accent-secondary: #2f81f7;
    --accent-danger: #da3633;
    
    /* Typography - GitHub Font Stack */
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    --font-editor: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    --font-markdown: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
    
    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    
    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-ui);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: -0.005em;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Main App Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-default);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-default);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.logo-icon {
    font-size: 20px;
}

.logo-image-small {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

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

.new-note-btn {
    width: 100%;
    background-color: var(--accent-primary);
    color: white;
    border: none;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    justify-content: center;
    transition: background-color 0.2s;
}

.new-note-btn:hover {
    background-color: #2ea043;
}

/* Search */
.sidebar-search {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-default);
}

.sidebar-search input {
    width: 100%;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-size: 14px;
}

.sidebar-search input:focus {
    outline: none;
    border-color: var(--accent-secondary);
    box-shadow: 0 0 0 2px rgba(47, 129, 247, 0.3);
}

.sidebar-search input::placeholder {
    color: var(--text-muted);
}

/* Navigation */
.sidebar-nav {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-default);
}

.nav-list {
    list-style: none;
}

.nav-item {
    margin-bottom: var(--space-1);
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.nav-item a:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active a {
    background-color: var(--bg-active);
    color: var(--text-primary);
    font-weight: 500;
}

/* Notes List */
.sidebar-notes {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2);
}

.note-item {
    padding: var(--space-3);
    margin-bottom: var(--space-1);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s;
    border-left: 3px solid transparent;
}

.note-item:hover {
    background-color: var(--bg-hover);
}

.note-item.active {
    background-color: var(--bg-active);
    border-left-color: var(--accent-secondary);
}

.note-item-title {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-item-preview {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.4;
    max-height: 2.8em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.note-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-2);
    font-size: 12px;
    color: var(--text-muted);
}

.note-starred {
    color: #ffd700;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: var(--space-4);
    border-top: 1px solid var(--border-default);
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.user-avatar {
    width: 32px;
    height: 32px;
    background-color: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
}

.logout-btn:hover {
    color: var(--text-primary);
}

/* Mobile elements hidden on desktop */
.mobile-overlay,
.mobile-header {
    display: none;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: var(--space-8);
    overflow-y: auto;
}

.welcome-content {
    max-width: 1200px;
    width: 100%;
    text-align: center;
}

.welcome-header h1 {
    font-size: 3em;
    margin-bottom: var(--space-3);
    color: var(--text-primary);
}

.welcome-header p {
    font-size: 1.2em;
    color: var(--text-secondary);
    margin-bottom: var(--space-8);
}

/* Template Grid */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-6);
    margin-bottom: var(--space-8);
}

.template-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.template-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.template-card:hover {
    background: var(--bg-hover);
    border-color: var(--accent-secondary);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(47, 129, 247, 0.15);
}

.template-card:hover::before {
    opacity: 1;
}

.template-icon {
    font-size: 3em;
    margin-bottom: var(--space-4);
    display: block;
}

.template-card h3 {
    font-size: 1.4em;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-3);
}

.template-card p {
    color: var(--text-secondary);
    font-size: 0.95em;
    line-height: 1.5;
    margin-bottom: var(--space-4);
}

.template-features {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    justify-content: center;
}

.feature-tag {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: 0.8em;
    font-weight: 500;
    border: 1px solid var(--border-muted);
}

.template-actions {
    text-align: center;
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-default);
}

/* Template-specific styling */
.template-card[data-template="plan"] .template-icon {
    color: #4ade80; /* Green */
}

.template-card[data-template="code"] .template-icon {
    color: #60a5fa; /* Blue */
}

.template-card[data-template="credentials"] .template-icon {
    color: #f59e0b; /* Amber */
}

/* Category-based Notes Organization */
.notes-category {
    margin-bottom: var(--space-4);
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-2);
    border-left: 3px solid var(--border-default);
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-header:hover {
    background: var(--bg-secondary);
    border-left-color: var(--accent-primary);
}

.category-icon {
    font-size: 16px;
    margin-right: var(--space-2);
}

.category-title {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.category-count {
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    min-width: 24px;
    text-align: center;
    border: 1px solid var(--border-muted);
}

.category-notes {
    padding-left: var(--space-2);
    border-left: 2px solid var(--border-muted);
    margin-left: var(--space-4);
}

.notes-category.collapsed .category-notes {
    display: none;
}

.notes-category.empty {
    opacity: 0.6;
}

.notes-category.empty .category-header {
    background: transparent;
    border-left-color: var(--border-muted);
}

/* Category-specific colors */
.notes-category[id="planNotesSection"] .category-header {
    border-left-color: #4ade80; /* Green */
}

.notes-category[id="codeNotesSection"] .category-header {
    border-left-color: #60a5fa; /* Blue */
}

.notes-category[id="credentialsNotesSection"] .category-header {
    border-left-color: #f59e0b; /* Amber */
}

.notes-category[id="otherNotesSection"] .category-header {
    border-left-color: #8b5cf6; /* Purple */
}



/* Buttons */
.btn-primary {
    background-color: var(--accent-primary);
    color: white;
    border: none;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #2ea043;
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
}

.btn-full {
    width: 100%;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    width: 400px;
    max-width: 90vw;
}

.modal-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-4);
}

/* Auth Form */
.auth-tabs {
    display: flex;
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-default);
}

.auth-tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.auth-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent-secondary);
}

.form-group {
    margin-bottom: var(--space-4);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-1);
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-secondary);
    box-shadow: 0 0 0 2px rgba(47, 129, 247, 0.3);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 260px; /* Slightly narrower on tablets */
    }
}

@media (max-width: 768px) {
    body {
        overflow: auto; /* Allow scrolling on mobile */
    }

    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh; /* Better mobile support */
    }
    
    .sidebar {
        width: 100%;
        position: fixed;
        top: 0;
        left: -100%;
        height: 100vh;
        height: 100dvh;
        transition: left 0.3s ease;
        z-index: 1000;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .main-content {
        width: 100%;
        flex: 1;
        min-height: 100vh;
        min-height: 100dvh;
    }

    /* Show mobile elements */
    .mobile-header {
        display: flex;
    }

    /* Mobile overlay for sidebar */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .mobile-overlay.show {
        opacity: 1;
        visibility: visible;
    }

    /* Mobile header for navigation */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--space-3) var(--space-4);
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-default);
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .mobile-menu-btn {
        background: none;
        border: none;
        color: var(--text-primary);
        font-size: 20px;
        cursor: pointer;
        padding: var(--space-2);
        border-radius: var(--radius-sm);
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
    }

    .mobile-menu-btn:hover {
        background: var(--bg-hover);
    }

    .mobile-title {
        font-size: 16px;
        font-weight: 600;
        color: var(--text-primary);
    }

    /* Sidebar adjustments for mobile */
    .sidebar-header {
        padding: var(--space-4) var(--space-4) var(--space-3);
    }

    .logo {
        margin-bottom: var(--space-3);
    }

    .new-note-btn {
        font-size: 14px;
        padding: var(--space-3);
    }

    .sidebar-search {
        padding: var(--space-3) var(--space-4);
    }

    .sidebar-nav {
        padding: var(--space-3) var(--space-4);
    }

    /* Notes list mobile optimization */
    .sidebar-notes {
        padding: 0 var(--space-4) var(--space-4);
    }

    .note-item {
        padding: var(--space-3);
        margin-bottom: var(--space-2);
    }

    .note-item-title {
        font-size: 14px;
        margin-bottom: var(--space-1);
    }

    .note-item-preview {
        font-size: 12px;
        line-height: 1.3;
        -webkit-line-clamp: 1; /* Single line on mobile */
        line-clamp: 1;
    }

    /* User info mobile */
    .sidebar-footer {
        padding: var(--space-3) var(--space-4);
    }

    .user-info {
        gap: var(--space-3);
    }

    .user-name {
        font-size: 13px;
    }

    /* Template grid mobile styles */
    .welcome-screen {
        padding: var(--space-4);
        align-items: flex-start;
        padding-top: 60px; /* Account for mobile header */
    }

    .welcome-header h1 {
        font-size: 2em;
    }

    .welcome-header p {
        font-size: 1em;
        margin-bottom: var(--space-6);
    }

    .template-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
        margin-bottom: var(--space-6);
    }

    .template-card {
        padding: var(--space-4);
    }

    .template-icon {
        font-size: 2.5em;
        margin-bottom: var(--space-3);
    }

    .template-card h3 {
        font-size: 1.2em;
        margin-bottom: var(--space-2);
    }

    .template-card p {
        font-size: 0.9em;
        margin-bottom: var(--space-3);
    }

    .template-features {
        gap: var(--space-1);
    }

    .feature-tag {
        font-size: 0.75em;
        padding: var(--space-1) var(--space-2);
    }
}

@media (max-width: 480px) {
    .app-container {
        height: auto;
    }

    .mobile-header {
        padding: var(--space-2) var(--space-3);
    }

    .mobile-title {
        font-size: 14px;
    }

    .sidebar-header {
        padding: var(--space-3);
    }

    .sidebar-search,
    .sidebar-nav,
    .sidebar-notes {
        padding: var(--space-2) var(--space-3);
    }

    .sidebar-footer {
        padding: var(--space-3);
    }

    .note-item {
        padding: var(--space-2);
    }

    .note-item-title {
        font-size: 13px;
    }

    .note-item-preview {
        font-size: 11px;
    }

    .note-item-meta {
        font-size: 10px;
    }

    .new-note-btn {
        padding: var(--space-2);
        font-size: 13px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-header {
        padding: var(--space-2) var(--space-4);
    }

    .sidebar-header {
        padding: var(--space-3) var(--space-4);
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}
