/* --- Global Variables & Reset --- */
:root {
    --bg-dark: #121212;
    --bg-panel: #1e1e1e;
    --text-primary: #e0e0e0;
    --text-secondary: #9aa0a6;
    --due-color: #ff5252;
    --do-color: #448aff;
    --project-color: #6cf80e;
    --border-color: #333;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Layout --- */
.app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
}

.sidebar {
    width: 100%;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.sidebar h2 {
    text-align: center;
    margin: 0;
    letter-spacing: 2px;
}

.nav-menu {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    text-align: center;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-btn.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-weight: bold;
}

.main-content {
    flex: 1;
    padding: 2rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    overflow-y: auto;
}

/* --- Header --- */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.add-btn {
    background-color: #00c853;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.add-btn:hover { background-color: #00e676; }

/* --- Data Grid & Task Cards --- */
.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.item-card {
    background-color: var(--bg-panel);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.item-card.due { border-left: 5px solid var(--due-color); }
.item-card.do { border-left: 5px solid var(--do-color); }
.item-card.project { border-left: 5px solid var(--project-color); }

/* Top Row Header Layout */
.item-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.type-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: bold;
}
.item-card.due .type-badge { background-color: rgba(255, 82, 82, 0.2); color: var(--due-color); }
.item-card.do .type-badge { background-color: rgba(91, 224, 13, 0.2); color: var(--do-color); }
.item-card.project .type-badge { background-color: rgba(108, 248, 14, 0.2); color: var(--project-color); }

/* Priority Colors (1=Red to 5=Green) */
.priority-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: bold;
    color: #121212;
}
.prio-1 { background-color: #f44336; color: white; }
.prio-2 { background-color: #ff9800; }
.prio-3 { background-color: #ffeb3b; }
.prio-4 { background-color: #aeea00; }
.prio-5 { background-color: #00c853; color: white; }

/* Icon Buttons & Links */
.icon-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
    padding: 0 0.2rem;
}
.link-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.icon-btn:hover { color: var(--text-primary); }
.edit-btn:hover { color: #ffeb3b; }
.complete-btn:hover { color: #00c853; }
.undo-btn:hover { color: #f44336; }
.link-btn:hover { color: var(--do-color); }

.date-text { 
    color: var(--text-secondary); 
    margin-left: auto;
}

.overdue-badge {
    background-color: #ffeb3b;
    color: #121212;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: bold;
}

/* Title & Description */
.card-toggle-area {
    cursor: pointer;
    margin-top: 0.5rem;
}

.card-title { 
    font-size: 1.05rem;
    font-weight: normal;
    margin: 0; 
    color: var(--text-primary);
}

.card-description {
    display: none;
    margin-top: 0.75rem;
    font-size: 1.15rem;
    color: var(--text-secondary);
    white-space: pre-line; 
    text-align: left;
}

.card-description.visible { display: block; }

.loading-text {
    color: var(--text-secondary);
    font-style: italic;
}

.section-divider {
    width: 100%;
    margin-top: 2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    grid-column: 1 / -1;
}

.section-divider h3 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

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

.modal.hidden { display: none; }

.modal-content {
    background-color: var(--bg-panel);
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-btn {
    background: none; border: none;
    color: var(--text-secondary);
    font-size: 1.5rem; cursor: pointer;
}
.close-btn:hover { color: white; }

/* --- Form Styles --- */
.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
    flex: 1;
}
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
label {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
input, select, textarea {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: 4px;
    font-size: 1rem;
    width: 100%;
    resize: vertical;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--do-color);
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
}
.action-right {
    display: flex;
    gap: 1rem;
    margin-left: auto;
}
.save-btn {
    background-color: var(--do-color);
    color: white; border: none; padding: 0.75rem 1.5rem;
    border-radius: 4px; cursor: pointer; font-weight: bold;
}
.cancel-btn {
    background: none; border: 1px solid var(--border-color);
    color: var(--text-primary); padding: 0.75rem 1.5rem;
    border-radius: 4px; cursor: pointer;
}
.delete-btn {
    background: none; border: 1px solid var(--due-color);
    color: var(--due-color); padding: 0.75rem 1.5rem;
    border-radius: 4px; cursor: pointer; font-weight: bold;
}
.delete-btn:hover {
    background-color: rgba(255, 82, 82, 0.1);
}
.delete-btn.hidden { display: none; }

/* Mobile / PWA View (Sliding Hamburger Menu) */
@media (max-width: 768px) {
    #hamburger-btn {
        display: block !important;
    }
    .sidebar {
        position: fixed;
        left: -250px;
        top: 0;
        height: 100vh;
        width: 250px;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 5px rgba(0,0,0,0.5);
        display: flex;
        flex-direction: column;
        background: var(--bg-panel);
        padding: 20px 10px;
    }
    .sidebar.open {
        left: 0;
    }
    .nav-btn {
        display: block;
        width: 100%;
        text-align: left;
        margin-bottom: 10px;
    }
}

/* Desktop Browser View (Permanent Left Sidebar) */
@media (min-width: 769px) {
    .app-container {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important; /* Forces top alignment for the container */
        height: 100vh;
        width: 100%;
    }
    .sidebar {
        width: 250px !important;
        min-width: 250px !important;
        height: 100vh !important;
        position: sticky !important;
        top: 0;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important; /* Forces items to the top */
        background: var(--bg-panel);
        border-right: 1px solid var(--border-color);
        padding: 20px;
        left: 0 !important; 
    }
    .nav-menu {
        display: flex !important;
        flex-direction: column !important; /* Forces buttons to stack vertically */
        width: 100%;
        margin-top: 20px;
    }
    .nav-btn {
        display: block !important;
        width: 100% !important;
        text-align: left !important;
        margin-bottom: 10px !important;
    }
    #hamburger-btn,
    #sidebar-overlay {
        display: none !important;
    }
    .main-content {
        flex: 1 !important;
        padding: 20px;
        overflow-y: auto;
        height: 100vh;
    }
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 999;
}

@media (max-width: 768px) {
    #hamburger-btn { display: block !important; }
    
    .sidebar-overlay.visible { display: block; }
    
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        height: 100vh;
        width: 260px;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 5px rgba(0,0,0,0.5);
        display: flex;
        flex-direction: column;
        justify-content: flex-start; /* Forces items to the top */
        padding-top: 20px;
    }
    .sidebar.open { left: 0; }
    
    .nav-menu {
        display: flex;
        flex-direction: column;
        width: 100%;
        margin-top: 20px;
    }
    
    .nav-btn {
        width: 100%;
        text-align: left; /* One item per line */
        padding: 15px 25px;
        margin-bottom: 5px;
        border-radius: 0;
    }
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-dark);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-overlay.hidden {
    display: none !important;
}
.login-card {
    background: var(--bg-panel);
    padding: 40px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    border: 1px solid var(--border-color);
}
.login-card h2 { margin-bottom: 10px; }
.login-card p { margin-bottom: 25px; color: var(--text-secondary); font-size: 14px; }
#token-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #2a2a2a;
    color: var(--text-primary);
    font-size: 16px;
}

/* Bill Summary Styling */
.bill-summary {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}
.summary-card {
    flex: 1;
    background: var(--bg-panel);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    text-align: center;
}
.summary-card h3 {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.summary-amount {
    margin: 10px 0 0 0;
    font-size: 24px;
    font-weight: bold;
}
/* Colorized Left Borders for Item Tiles */
.item-card.due { border-left: 5px solid #10B981; }
.item-card.do { border-left: 5px solid #6366F1; }
.item-card.project { border-left: 5px solid #F59E0B; }