/* --- Core Variables & Setup --- */
:root {
    --bg-dark: #1a1a2e;
    --bg-medium: #16213e;
    --primary-glow: #0f3460;
    --accent-teal: #537fe7;
    --accent-purple: #9370db;
    --text-color: #e4e6eb;
    --error-color: #e74c3c;
    --font-header: 'Cinzel Decorative', cursive;
    --font-body: 'Roboto', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-color);
    font-family: var(--font-body);
    margin: 0;
    overflow: hidden;
}

/* --- Login/Register Page --- */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
}
.login-container h1 {
    font-family: var(--font-header);
    font-size: 3rem;
    color: var(--accent-teal);
    text-shadow: 0 0 15px var(--accent-teal);
    margin-bottom: 30px;
}
.login-container form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 320px;
    background: var(--bg-medium);
    padding: 30px;
    border-radius: 10px;
    border: 1px solid var(--primary-glow);
}
.login-container h2 {
    margin: 0 0 10px 0;
    font-family: var(--font-header);
    font-weight: normal;
    text-align: center;
}
.login-container input {
    background: var(--bg-dark);
    border: 1px solid var(--primary-glow);
    color: var(--text-color);
    padding: 12px;
    border-radius: 5px;
    font-size: 1rem;
}
.login-container input:focus {
    outline: none;
    border-color: var(--accent-teal);
    box-shadow: 0 0 10px var(--accent-teal);
}
.login-container button {
    background: var(--accent-purple);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1rem;
    font-family: var(--font-header);
    transition: background-color 0.3s;
}
.login-container button:hover {
    background: #a380eb;
}
.form-toggle {
    text-align: center;
    font-size: 0.9rem;
}
.form-toggle a {
    color: var(--accent-teal);
    text-decoration: none;
    cursor: pointer;
}
.error-message {
    margin-top: 20px;
    color: var(--error-color);
    background: rgba(231, 76, 60, 0.1);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid var(--error-color);
}


/* --- OS Desktop --- */
#desktop {
    position: relative;
    width: 100vw;
    height: 100vh;
}
.desktop-background {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--bg-dark) url('https://www.transparenttextures.com/patterns/stardust.png');
    opacity: 0.5;
    z-index: -1;
}
#dock {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 52, 96, 0.5);
    border: 1px solid var(--accent-teal);
    border-radius: 15px;
    padding: 10px;
    display: flex;
    gap: 15px;
    backdrop-filter: blur(10px);
    z-index: 1000;
}
.glyph {
    width: 60px; height: 60px;
    border: 2px solid var(--accent-purple);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: var(--font-header);
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}
.glyph:hover {
    background-color: var(--primary-glow);
    box-shadow: 0 0 20px var(--accent-purple);
    transform: translateY(-5px);
}
.user-info {
    position: fixed;
    top: 10px;
    right: 20px;
    font-size: 0.9rem;
    z-index: 1000;
}
.user-info a {
    color: var(--accent-teal);
    text-decoration: none;
}

/* --- App Window Styling --- */
.window {
    position: absolute;
    top: 20%; left: 20%;
    width: 500px;
    height: 400px;
    background: var(--bg-medium);
    border: 1px solid var(--accent-teal);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    z-index: 100;
    resize: both;
    overflow: hidden; /* Important for resize */
}
.window.active {
    z-index: 101;
    box-shadow: 0 0 25px var(--accent-teal);
}
.window-header {
    background-color: var(--primary-glow);
    padding: 8px 12px;
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-header);
    flex-shrink: 0;
}
.window-header span:first-child {
    text-transform: capitalize;
}
.window-close { cursor: pointer; padding: 0 5px; }
.window-body {
    padding: 15px;
    flex-grow: 1;
    overflow-y: auto;
    display: flex; /* For splitting panes */
    gap: 10px;
}

/* --- App Specific UI --- */
.app-sidebar {
    width: 150px;
    flex-shrink: 0;
    border-right: 1px solid var(--primary-glow);
    padding-right: 10px;
    overflow-y: auto;
}
.app-main-content {
    flex-grow: 1;
}

.sidebar-item {
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-item:hover {
    background-color: var(--primary-glow);
}
.sidebar-item.selected {
    background-color: var(--accent-teal);
    color: var(--bg-dark);
    font-weight: bold;
}
.app-button {
    width: 100%;
    background: var(--accent-purple);
    color: white;
    border: none;
    padding: 8px;
    margin-bottom: 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}
.app-button:hover {
    background-color: #a380eb;
}
.app-button.delete {
    background-color: var(--error-color);
}
.app-button.delete:hover {
    background-color: #c0392b;
}

.editor-form input, .editor-form textarea {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-dark);
    border: 1px solid var(--primary-glow);
    color: var(--text-color);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
    font-family: var(--font-body);
}
.editor-form textarea {
    height: 200px;
    resize: vertical;
}

/*
========================================
    RESPONSIVE DESIGN (MOBILE & TABLET)
========================================
*/
@media (max-width: 768px) {

    /* --- Login Page Adjustments --- */
    .login-container h1 {
        font-size: 2.5rem; /* Slightly smaller title */
    }
    .login-container form {
        width: 90%; /* Make forms fluid */
        padding: 20px;
    }

    /* --- Dock Transformation --- */
    #dock {
        width: 100%;
        bottom: 0;
        left: 0;
        transform: none; /* Override desktop centering */
        border-radius: 0; /* Make it a bar */
        border-left: none;
        border-right: none;
        border-top: 1px solid var(--accent-teal);
        justify-content: space-around; /* Space out icons evenly */
        padding: 5px 0;
    }
    .glyph {
        width: 65px;   /* Larger tap targets */
        height: 65px;
        font-size: 2rem;
    }
    .glyph:hover {
        transform: none; /* Disable hover movement on touch devices */
    }


    /* --- App Window: The Fullscreen Takeover --- */
    .window {
        /* This is the key change: make the window a fullscreen panel */
        position: fixed; /* Fixed to the viewport */
        width: 100vw !important;  /* Use viewport units to fill the screen */
        height: 100vh !important;
        top: 0 !important;
        left: 0 !important;
        border-radius: 0;
        border: none;
        resize: none; /* Disable resizing on mobile */
        z-index: 2000; /* Ensure it's on top of everything */
    }
    .window-header {
        border-radius: 0;
    }


    /* --- App Content Layout: Stack Vertically --- */
    .window-body {
        flex-direction: column; /* Stack sidebar and main content */
    }
    .app-sidebar {
        width: 100%;
        flex-shrink: 1;
        border-right: none;
        border-bottom: 1px solid var(--primary-glow);
        padding-right: 0;
        padding-bottom: 10px;
        max-height: 200px; /* Give the list a max height so it can scroll */
        overflow-y: auto;
    }
    .app-main-content {
        flex-grow: 1; /* Allow main content to fill remaining space */
        overflow-y: auto;
    }
    .editor-form textarea {
        height: 150px; /* Adjust textarea for smaller screen */
    }

}

/* --- Enhanced Delete Section Styling --- */
.delete-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--primary-glow);
}

.delete-toggle {
    background: var(--bg-dark) !important;
    border: 1px solid #666 !important;
    color: #ccc !important;
    font-size: 0.9rem;
}

.delete-toggle:hover {
    background: var(--primary-glow) !important;
    border-color: #888 !important;
    color: var(--text-color) !important;
}

.delete-confirm {
    margin-top: 10px;
    padding: 15px;
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid var(--error-color);
    border-radius: 5px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.delete-warning {
    margin: 0 0 10px 0;
    color: var(--error-color);
    font-weight: bold;
    text-align: center;
    font-size: 0.9rem;
}

.delete-cancel {
    background: var(--bg-dark) !important;
    border: 1px solid #666 !important;
    color: var(--text-color) !important;
    margin-right: 10px;
}

.delete-cancel:hover {
    background: var(--primary-glow) !important;
    border-color: var(--accent-teal) !important;
}

.delete-confirm-btn {
    background: var(--error-color) !important;
    color: white !important;
}

.delete-confirm-btn:hover {
    background: #c0392b !important;
}

.delete-confirm-btn:disabled {
    background: #666 !important;
    cursor: not-allowed;
}

/* --- Mobile Responsive Adjustments --- */
@media (max-width: 768px) {
    .delete-confirm {
        padding: 10px;
    }
    
    .delete-cancel,
    .delete-confirm-btn {
        display: block;
        width: 100%;
        margin: 5px 0;
    }
    
    .delete-cancel {
        margin-right: 0;
    }
}