@import url('../../common/css/variables.css');

/* --- Reset & Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

body[data-tg="1"] {
    overflow: auto;
}

body[data-tg="1"] .left_panel {
    display: none;
}

body[data-tg="1"] .main_section {
    height: auto;
    min-height: 100vh;
}

body[data-tg="1"] .right_panel,
body[data-tg="1"] .calendar-section,
body[data-tg="1"] .conban-board {
    padding: var(--space-16);
}

/* --- Layout Structure --- */
.main_section {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.left_panel {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: var(--space-16);
    flex-shrink: 0;
    z-index: 50;
    transition: width var(--ease-default);
}

.image-link {
    align-self: flex-start;
    margin-left: var(--space-12);
    margin-bottom: var(--space-24);
    display: block;
    text-decoration: none;
}

.image {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background-color: var(--bg-element);
    background-size: cover;
    background-position: center;
    transition: transform 0.2s;
}

.image:hover {
    transform: scale(1.05);
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.navigation {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    flex: 1;
}

/* Nav Items */
.navigation_button {
    border-radius: var(--radius-md);
    transition: background-color var(--ease-default);
}

.navigation_button a,
.navigation_button button {
    display: flex;
    align-items: center;
    gap: var(--space-12);
    width: 100%;
    padding: var(--space-8) var(--space-12);
    color: var(--text-secondary);
    text-decoration: none;
    background: none;
    border: none;
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.navigation_button:hover a,
.navigation_button:hover button,
.navigation_button.active a {
    color: var(--text-primary);
    background-color: var(--bg-element);
    border-radius: var(--radius-md);
}

.navigation_button svg,
.sleep-settings-icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.navigation_button:hover svg {
    opacity: 1;
}

/* --- Main Content Area --- */
/* Replacing .glass-block logic with generic container styles if needed, 
   but specific pages will handle their own layout */

/* --- UI Components --- */

/* Buttons */
.btn, .glass-input-button, .modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-8) var(--space-16);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-element);
    color: var(--text-primary);
    transition: all var(--ease-default);
    text-decoration: none;
}

.btn:hover, .glass-input-button:hover, .modal-btn:hover {
    background-color: var(--bg-element-hover);
    border-color: var(--text-secondary);
}

.btn-primary {
    background-color: var(--accent-primary);
    color: var(--text-inverse);
    border: none;
}

.btn-primary:hover {
    background-color: var(--accent-primary-hover);
}

/* Inputs */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="datetime-local"],
select,
.glass-input-text,
.glass-input-daytime,
.modal-input-custom {
    background-color: var(--bg-app);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: var(--space-8) var(--space-12);
    font-size: 16px;
    font-family: inherit;
    width: 100%;
    transition: border-color var(--ease-default);
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-element);
    border-radius: 5px;
    border: 2px solid var(--bg-app); /* padding effect */
}

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

/* --- Utilities --- */
.hide {
    display: none !important;
}

.glass-block {
    /* Legacy class support - mapped to surface */
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    backdrop-filter: none;
}

/* --- Custom Select (Global) --- */
.custom-select-container {
    position: relative;
    font-size: var(--text-sm);
}

.custom-select-label {
    display: block;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-4);
}

.custom-select-trigger {
    background-color: var(--bg-app);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-8) var(--space-12);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 38px;
    transition: border-color 0.2s;
}

.custom-select-trigger:focus,
.custom-select-container.open .custom-select-trigger {
    border-color: var(--text-tertiary);
    outline: none;
}

.custom-select-content {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    flex: 1;
}

.custom-select-arrow {
    color: var(--text-secondary);
    margin-left: var(--space-8);
}

.custom-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    margin-top: var(--space-4);
    display: none;
    overflow: hidden;
    flex-direction: column;
}

.custom-select-container.open .custom-select-dropdown {
    display: flex;
}

.custom-select-search {
    width: 100%;
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    background-color: var(--bg-surface);
    padding: var(--space-8) var(--space-12);
    color: var(--text-primary);
    font-size: var(--text-sm);
}

.custom-select-search:focus {
    outline: none;
}

.custom-select-list {
    max-height: 200px;
    overflow-y: auto;
}

.custom-select-option {
    padding: var(--space-8) var(--space-12);
    cursor: pointer;
    color: var(--text-primary);
    transition: background-color 0.1s;
}

.custom-select-option:hover {
    background-color: var(--bg-element);
}

.custom-select-option.selected {
    background-color: rgba(88, 166, 255, 0.1);
    color: var(--accent-primary);
}

.custom-select-empty {
    padding: var(--space-12);
    color: var(--text-secondary);
    text-align: center;
}

/* Tags in Trigger */
.custom-select-tag {
    background-color: var(--bg-element);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    font-size: var(--text-xs);
    display: flex;
    align-items: center;
    gap: 4px;
}

.tag-remove {
    cursor: pointer;
    opacity: 0.6;
    font-size: 14px;
    line-height: 1;
}

.tag-remove:hover {
    opacity: 1;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    html {
        height: auto;
        min-height: 100%;
        overflow-y: auto;
        overflow-x: hidden;
    }

    body {
        height: auto;
        min-height: 100vh;
        overflow-y: visible;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }

    .main_section {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .left_panel {
        width: 100%;
        height: auto;
        flex-direction: row;
        padding: var(--space-8);
        border-right: none;
        border-top: 1px solid var(--border-subtle);
        justify-content: space-around;
        position: fixed;
        bottom: 0;
        left: 0;
        background-color: var(--bg-surface); /* Solid bg for nav */
        z-index: 1000;
    }

    .image {
        display: none;
    }

    .navigation {
        flex-direction: row;
        width: 100%;
        justify-content: flex-start; /* Changed from space-between */
        overflow-x: auto; /* Enable horizontal scroll */
        gap: var(--space-8); /* Add gap between items */
        padding-bottom: env(safe-area-inset-bottom); /* Safe area for iOS */
    }

    .navigation::-webkit-scrollbar {
        display: none; /* Hide scrollbar for cleaner look */
    }

    .navigation_button {
        flex: 0 0 auto; /* Don't shrink, don't grow excessively */
        display: flex;
        justify-content: center;
        min-width: 60px; /* Ensure touch target size */
    }

    .navigation_button a,
    .navigation_button button {
        flex-direction: column;
        gap: var(--space-4);
        padding: var(--space-4);
        font-size: 10px;
        text-align: center;
    }

    .navigation_button svg {
        width: 24px;
        height: 24px;
    }
    
    /* Adjust content area to not be hidden behind bottom nav */
    .right_panel, .calendar-section, .conban-board {
        height: auto !important;
        min-height: 100vh;
        overflow: visible !important;
        padding-bottom: 100px; /* Space for bottom nav */
    }
}
