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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

#app:not(.button-grid) {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Main tabs styling */
#main-tabs {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tabs-left {
    display: flex;
    gap: 10px;
}

.tabs-right {
    display: flex;
    gap: 10px;
}

.tab-button {
    padding: 8px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    border-radius: 4px;
    transition: all 0.2s;
}

.tab-button:hover {
    background-color: #f0f0f0;
}

.tab-button.active {
    color: #000;
    background-color: #e0e0e0;
    font-weight: 500;
}

.control-button {
    padding: 8px 16px;
    text-decoration: none;
    color: #666;
    border-radius: 4px;
    transition: all 0.2s;
}

.control-button:hover {
    background-color: #f0f0f0;
    color: #000;
}

/* Main content area */
#main-content {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-height: 400px;
    padding: 20px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Options tabs styling */
#options-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.subtab-button {
    padding: 8px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    border-radius: 4px;
    transition: all 0.2s;
}

.subtab-button:hover {
    background-color: #f0f0f0;
}

.subtab-button.active {
    color: #000;
    background-color: #e0e0e0;
    font-weight: 500;
}

.subtab-content {
    display: none;
}

.subtab-content.active {
    display: block;
}

/* Canvas controls */
#canvas-controls {
    margin-top: 20px;
    padding: 10px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#canvas-controls.hidden {
    display: none;
}

/* Note selection popup */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.popup.hidden {
    display: none;
}

.popup-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
    width: 400px;
}

/* Note Tree Styles */
.note-tree {
    list-style: none;
    padding-left: 20px;
    margin: 0;
}

.note-tree.root {
    padding-left: 0;
}

.note-item {
    margin: 5px 0;
    cursor: pointer;
}

.expand-btn {
    background: none;
    border: none;
    width: 20px;
    height: 20px;
    padding: 0;
    margin-right: 5px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    text-align: center;
    color: #666;
}

.note-title {
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.note-title:hover {
    background-color: #f0f0f0;
}

.note-tree.collapsed {
    display: none;
}

/* Responsive design */
@media (max-width: 768px) {
    #app {
        padding: 10px;
    }

    #main-tabs {
        flex-direction: column;
        gap: 10px;
    }

    .tabs-left,
    .tabs-right {
        width: 100%;
        justify-content: center;
    }

    .tab-button,
    .control-button {
        padding: 6px 12px;
        font-size: 14px;
    }

    #options-tabs {
        flex-wrap: wrap;
        justify-content: center;
    }

    .subtab-button {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* Front page grid of large buttons */
.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    max-width: 900px;
    margin: 40px auto;
    padding: 20px;
}

.button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    font-size: 1.25rem;
    font-weight: 600;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 12px;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-align: center;
    line-height: 1.4;
}

.button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.button:hover::before,
.button:focus::before {
    opacity: 1;
}

.button:hover,
.button:focus {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    background: #0056b3;
}

.button:active {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Alternate button colors for variety - subtle variations */
.button:nth-child(2n) {
    background: #6c757d;
}

.button:nth-child(2n):hover,
.button:nth-child(2n):focus {
    background: #5a6268;
}

.button:nth-child(3n) {
    background: #17a2b8;
}

.button:nth-child(3n):hover,
.button:nth-child(3n):focus {
    background: #138496;
}

.button:nth-child(4n) {
    background: #28a745;
}

.button:nth-child(4n):hover,
.button:nth-child(4n):focus {
    background: #218838;
}

.button:nth-child(5n) {
    background: #5a6268;
}

.button:nth-child(5n):hover,
.button:nth-child(5n):focus {
    background: #4e555b;
}

@media (max-width: 768px) {
    .button-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 16px;
        padding: 16px;
        margin: 30px auto;
    }

    .button {
        font-size: 1rem;
        padding: 24px 16px;
    }
}

@media (max-width: 480px) {
    .button-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .button {
        padding: 20px 16px;
    }
}

/* PWA install button */
.pwa-install-btn {
    display: block;
    width: calc(100% - 40px);
    max-width: 900px;
    margin: 28px auto 0;
    padding: 16px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    background: linear-gradient(135deg, #6610f2 0%, #a855f7 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    box-shadow: 0 4px 16px rgba(102, 16, 242, 0.35);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    letter-spacing: 0.02em;
}

.pwa-install-btn:hover,
.pwa-install-btn:focus {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 16, 242, 0.45);
    background: linear-gradient(135deg, #5a0be0 0%, #9333ea 100%);
}

.pwa-install-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(102, 16, 242, 0.25);
}

/* Hide install button when already running as an installed app */
@media (display-mode: standalone) {
    #pwa-install-btn {
        display: none !important;
    }
}

@media (display-mode: fullscreen) {
    #pwa-install-btn {
        display: none !important;
    }
}