:root {
    --primary-color: #f5f5f5;
    --secondary-color: #a3aab5;
    --tertiary-color: #242424;
    --accent-color: #e24ad3;
    --accent-red: #c41e3a;
    --text-color: #161616;
    --light-bg: #e6e8ed;
    --dark-bg: #4d4d4e;
    --header-height: 60px;
    --footer-height: 60px;
    --nav-width: 250px;
    --nav-width-collapsed: 70px;
}

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

body {
    font-family: 'Atkinson Hyperlegible Mono', 'Roboto Mono', sans-serif, monospace;
    color: var(--text-color);
}

/* Grid Layout */
.grid-container {
    display: grid;
    min-height: 100vh;
    grid-template-areas:
        "header header"
        "nav main"
        "footer footer";
    grid-template-columns: var(--nav-width) 1fr;
    grid-template-rows: var(--header-height) 1fr var(--footer-height);
    transition: grid-template-columns 0.3s ease;
}

.grid-container.nav-collapsed {
    grid-template-columns: var(--nav-width-collapsed) 1fr;
}

/* Header */
header {
    grid-area: header;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    background-color: var(--secondary-color);
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    height: 24px;
    cursor: pointer;
}

.mobile-menu-toggle span {
    display: block;
    height: 3px;
    width: 30px;
    background: white;
    border-radius: 3px;
    margin: 4px 0;
    list-style: none;
}

/* Navigation */
.main-nav {
    grid-area: nav;
    background-color: var(--light-bg);
    border-right: 1px solid #ddd;
    padding: 20px 0;
    overflow-y: auto;
    position: relative;
    transition: width 0.3s ease;
}

.nav-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background: var(--light-bg);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.grid-container.nav-collapsed .nav-toggle {
    transform: rotate(180deg);
}

.nav-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 30px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--tertiary-color);
    background-color: var(--primary-color);
    text-decoration: none;
    border-radius: 4px;
    margin: 0 10px;
    transition: background-color 0.3s;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item:hover,
.nav-item.active {
    background-color: rgba(36, 36, 36, 0.1);
    color: var(--tertiary-color);
}

.nav-item .icon {
    margin-right: 15px;
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
}

.grid-container.nav-collapsed .nav-item span {
    display: none;
}

/* Main Content */
main {
    grid-area: main;
    background-color: var(--primary-color);
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* login and sign up forms */

.minimal-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--primary-color);
}

.minimal-layout .main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-container {
    width: 100%;
    max-width: 500px;
    text-align: center;
}

.auth-header {
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.minimal-layout footer {
    text-align: center;
    padding: 1rem;
    background-color: white;
    border-top: 1px solid #eee;
}

/* Messages */
.messages {
    margin-bottom: 20px;
}

.message {
    padding: 10px 15px;
    margin-bottom: 10px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.message.success {
    background-color: #d4edda;
    color: #155724;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
}

.message.warning {
    background-color: #fff3cd;
    color: #856404;
}

.message.info {
    background-color: #d1ecf1;
    color: #0c5460;
}

.message-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.7;
}

.message-close:hover {
    opacity: 1;
}

/* Footer */
footer {
    grid-area: footer;
    background-color: var(--tertiary-color);
    color: white;
    text-align: center;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-icon {
    display: flex;
    align-items: center;
    position: relative;
}

.user-icon .icon {
    color: var(--primary-color);
    font-size: 1.2rem;
}

/* Optional: Add notification dot to show unread items */
.user-icon .notification-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 8px;
    background-color: #951408;
    border-radius: 50%;
}

/* Form Styles - Global */
.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

.form-group label {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--tertiary-color);
    font-weight: 300;
}

input, textarea, select {
    border: 1px solid var(--dark-bg);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 1rem;
    background: var(--primary-color);
    transition: all 0.2s ease;
    font-family: inherit;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--tertiary-color);
    outline: solid;
    background: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}

button, .btn {
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 12px 24px;
    font-size: .8rem;
    font-weight: 200;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}


.btn-outline-default, button[type="submit"] {
    background: transparent;
    color: var(--tertiary-color);
    border: 1px solid var(--tertiary-color);
    box-shadow: none;
}

.btn-outline-default:hover, button[type="submit"]:hover {
    background: var(--primary-color);
    color: var(--tertiary-color);
    border-color: var(--tertiary-color);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.9rem;
    border-radius: 6px;
}

/* Card Styles - Global */
.card {
    background: white;
    border: 1px solid var(--secondary-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.card:hover {
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Routines List Styles */
.routines-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e5e7eb;
}

.header-section h2 {
    margin: 0;
    color: #333;
    font-size: 2.5rem;
}

.new-routine-btn {
    padding: 12px 24px;
    font-size: 1rem;
    color: var(--text-color);
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--tertiary-color);
    text-decoration: none;
    transition: all 0.3s ease;
}

.new-routine-btn:hover {
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--primary-color);
}

/* Grid Layout */
.routines-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

/* Card Styles */
.routine-card {
    background: white;
    border: 2px solid black;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.routine-card:hover {
    border-color: var(--accent-red);
    transform: translateY(-4px);
}

.card-header {
    padding: 20px;
    background: var(--primary-color);
    border-bottom: 2px solid #e5e7eb;
}

.routine-name {
    margin: 0 0 8px 0;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-color);
}

.routine-time {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--tertiary-color);
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.card-body {
    padding: 20px;
}

.routine-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 10px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-color);
    line-height: 1;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 2px;
}

/* Action Buttons */
.card-actions {
    display: flex;
    padding: 20px;
    gap: 8px;
    border-top: 2px solid #f1f3f4;
}

.card-actions .btn {
    flex: 1;
    text-align: center;
    color: var(--text-color);
    background: transparent;
    border: 1px solid var(--tertiary-color);
    transition: color 0.2s, border-color 0.2s;
    font-size: 0.8rem; 
    padding: 8px 12px;
}

/* Hover: accent red */
.card-actions .btn:hover,
.card-actions .btn:focus {
    color: var(--primary-color);
    border-color: var(--accent-red);
    background: var(--accent-red);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.empty-icon {
    font-size: 4rem;
    color: #6c757d;
    margin-bottom: 20px;
}

.empty-state h2 {
    color: #333;
    margin-bottom: 10px;
}

.empty-state p {
    color: #6c757d;
    font-size: 1.1rem;
    margin-bottom: 30px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .routines-grid .routine-card {
        border: 1px solid var(--secondary-color) !important;
    }

    .routines-container {
        padding: 15px;
    }
    
    .header-section {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .header-section h1 {
        font-size: 1.5rem;
    }
    
    .routines-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .card-actions {
        flex-direction: column;
    }


    
    .card-header {
        padding: 15px;
    }
    
    .routine-name {
        font-size: 1rem;
    }
    
    .empty-state {
        padding: 40px 15px;
    }


    /* Layout Containers */
    .container {
        width: 100%;
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 20px;
    }

    .container-sm {
        max-width: 600px;
    }

    .container-lg {
        max-width: 1400px;
    }

    /* Grid System */
    .grid {
        display: grid;
        gap: 20px;
    }

    .grid-1 { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-auto { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }


    /* Ensure footer stays at the bottom on mobile */
    body, .minimal-layout {
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }


    main, .main-content {
        flex: 1 1 auto;
        display: none;
    }
    
    footer {
        margin-top: auto;
    }

    .grid-container {
        min-height: 100vh;
        display: grid;
        grid-template-areas:
            "header"
            "nav"
            "main"
            "footer";
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-height) 1fr var(--footer-height);
    }
    .main-nav {
        grid-area: nav;
        width: 100vw;
        min-width: 0;
        max-width: 100vw;
        border-right: none;
        border-bottom: 1px solid #ddd;
        box-shadow: none;
        padding: 0;
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    .nav-panel h1,
    .nav-panel h2,
    .nav-panel h3,
    .nav-panel h4,
    .nav-panel h5,
    .nav-panel h6,
    .nav-item-container h1,
    .nav-item-container h2,
    .nav-item-container h3,
    .nav-item-container h4,
    .nav-item-container h5,
    .nav-item-container h6 {
        font-size: 1.2rem;
        font-weight: 400;
        letter-spacing: 0.02em;
        margin-top: 0;
        margin-bottom: 28px;
        color: #333;
        line-height: 1.3;
    }
    
    .nav-content {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;
    }

    .nav-item-container {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .nav-item {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        padding: 12px 20px;
        color: var(--tertiary-color);
        background-color: var(--primary-color);
        text-decoration: none;
        border-radius: 0;
        margin: 0;
        width: 100%;
        min-height: 56px;
        border-bottom: 1px solid #eee;
        font-size: 1.1rem;
        justify-content: flex-start;
    }

    .nav-panel {
        flex: 1 1 auto;
        display: none;
        width: 100%;
        background: var(--primary-color);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
        position: static;
        height: 100%;
        max-height: none;
        overflow: auto;
        padding: 0;
    }

    .nav-panel.active {
        display: block;
        padding: 16px 12px;
        animation: fadeIn 0.2s;
        height: 100%;
    }

    .contact-form-panel {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        min-height: 0;
        padding: 32px 16px;
        box-sizing: border-box;
        width: 100%;
        height: 100%;
    }

    .routine-builder {
        max-width: 800px;
        margin: 0 auto;
    }

    .task-list,
    .add-task {
        margin-bottom: 2rem;
        padding: 1.5rem;
        background-color: var(--primary-color);
        border-radius: 5px;
    }


    .tasks {
        list-style: none;
        padding: 0;
    }

    .task-item {
        display: flex;
        justify-content: space-between;
        padding: 0.75rem;
        background-color: var(--primary-color);
        margin-bottom: 0.5rem;
        border-radius: 4px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    .total-time {
        text-align: right;
        font-size: 1.1em;
        margin: 1rem 1rem;
    }

    .save-form,
    .start-form {
        display: inline-block;
        margin-right: 1rem;
        margin-bottom: auto;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .form-error {
        color: #dc3545;
        font-size: 0.875em;
        margin-top: 0.25rem;
    }

    .live-preview {
        background-color: var(--primary-color);
        border-radius: 8px;
        padding: 15px;
        margin: 20px 0;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        transition: all 0.3s ease;
    }

    .live-preview h2 {
        margin-top: 0;
        color: #343a40;
        border-bottom: 1px solid #dee2e6;
        padding-bottom: 10px;
    }

    .preview-name {
        margin-bottom: 15px;
        font-size: 1.1em;
    }

    .task-item.preview-only {
        border-left: 3px solid var(--tertiary-color);
        opacity: 0.8;
        background-color: rgba(0, 123, 255, 0.05);
    }

    .form-actions {
        display: flex;
        gap: 15px;
        margin-top: 20px;
    }

    .form-actions form {
        display: inline-block;
    }

    .form-actions button {
        margin: auto 0;
    }

    .task-form {
        margin-bottom: 30px;
    }

    #panel-standalone-timer.active .timer-centerpiece {
        min-height: 60vh; /* or more if needed for your dial */
    }

    .timer-centerpiece {
        display: flex;
        flex-direction: column;
        align-items: center;
        flex: 1 1 auto;
        height: 100%;
        min-height: 0; /* Center content vertically */
    }

    #timer-dial {
        flex: 1 1 auto;
        width: 100%;
        max-width: 300px;
        min-width: 120px;
        min-height: 0;
        display: block;
        aspect-ratio: 1 / 1;
    }

    .timer-bottom-group {
        margin-top: auto;
        margin-bottom: 2rem;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    /* Standalone Timer Mobile Styles */
    .standalone-timer #decrement-10,
    .standalone-timer #decrement-5,
    .standalone-timer #decrement-1, 
    .standalone-timer #increment-5,
    .standalone-timer #increment-10 {
        display: none;
    }

    .standalone-timer #increment-1 {
        display: inline-flex;
    }

    .standalone-timer .mobile-top-controls {
        display: flex;
        justify-content: center;
        gap: 12px;
        margin-bottom: 20px;
    }

    .standalone-timer .mobile-bottom-controls {
        display: flex;
        justify-content: center;
        gap: 20px;
        margin-top: 16px;
    }

    .standalone-timer .desktop-controls {
        display: none;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
}

@media (min-width: 769px) {
    .standalone-timer .mobile-top-controls,
    .standalone-timer .mobile-bottom-controls {
        display: none;
    }
    
    .standalone-timer .desktop-controls {
        display: flex;
        justify-content: center;
        gap: 8px;
    }
}