:root {
    --bg-primary: #f5f5f7;
    --bg-card: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --accent: #000000;
    --accent-hover: #333333;
    --border: #d2d2d7;
    --success: #34c759;
    --danger: #ff3b30;
    --warning: #ff9500;
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 48px rgba(0,0,0,0.12);
    --navbar-height: 64px;
    --weekbar-height: 100px;
}

* {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    box-sizing: border-box;
}

body {
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
}

/* ==================== LOGIN ==================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    padding: 48px;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-logo p {
    color: var(--text-secondary);
    margin-top: 8px;
    font-size: 1rem;
}

/* ==================== APP WRAPPER ==================== */
.app-wrapper {
    display: none;
    flex-direction: column;
    min-height: 100vh;
}

/* ==================== TOP NAVBAR ==================== */
.top-navbar {
    height: var(--navbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.navbar-left {
    display: flex;
    align-items: center;
}

.navbar-logo {
    height: 36px;
}

.navbar-center {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-nav {
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-nav:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-icon-nav {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1.1rem;
}

.btn-icon-nav:hover {
    background: var(--accent);
    color: #fff;
}

.user-badge {
    background: var(--bg-primary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.user-badge.admin {
    background: var(--accent);
    color: #fff;
}

#userName {
    font-weight: 500;
    font-size: 0.9rem;
}

/* ==================== MAIN LAYOUT ==================== */
.main-layout {
    display: flex;
    margin-top: var(--navbar-height);
    margin-bottom: var(--weekbar-height);
    min-height: calc(100vh - var(--navbar-height) - var(--weekbar-height));
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 20px;
    height: calc(100vh - var(--navbar-height) - var(--weekbar-height));
    overflow-y: auto;
    position: fixed;
    left: 0;
    top: var(--navbar-height);
}

.sidebar-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding: 0 12px;
}

.project-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.project-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 10px;
    margin-bottom: 4px;
}

.project-item:hover {
    background: var(--bg-primary);
}

.project-item.active {
    background: var(--accent);
    color: #fff;
}

.project-item i {
    font-size: 1rem;
}

.project-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-count {
    background: rgba(0,0,0,0.08);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.project-item.active .project-count {
    background: rgba(255,255,255,0.2);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px;
    overflow-y: auto;
}

/* ==================== BOTTOM WEEK BAR ==================== */
.week-bar-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--weekbar-height);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.week-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 700px;
    width: 100%;
    padding: 0 20px;
}

.week-nav-btn {
    width: 44px;
    height: 44px;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: var(--text-primary);
    font-size: 1.1rem;
    flex-shrink: 0;
}

.week-nav-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.week-content {
    flex: 1;
    text-align: center;
}

.week-header {
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
}

.week-days {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.day-item {
    flex: 1;
    text-align: center;
    padding: 10px 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    min-width: 50px;
}

.day-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.day-item.active {
    background: var(--accent);
    color: #fff;
}

.day-item.today:not(.active) {
    border: 2px solid var(--accent);
}

.day-name {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.day-item:not(.active) .day-name {
    color: var(--text-secondary);
}

.day-number {
    font-size: 1.2rem;
    font-weight: 700;
}

/* ==================== CARDS ==================== */
.card-main {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

/* ==================== FORMS ==================== */
.form-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    margin-bottom: 12px;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
}

.btn-primary-custom {
    width: 100%;
    padding: 14px 28px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary-custom:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary-custom {
    padding: 10px 20px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-secondary-custom:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #e6342b;
    border-color: #e6342b;
    color: #fff;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
}

/* ==================== TODO LIST ==================== */
.todo-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.todo-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-primary);
    border-radius: 12px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
    gap: 12px;
}

.todo-item:hover {
    transform: translateX(4px);
}

.todo-item.completed {
    opacity: 0.5;
}

.todo-item.completed .todo-text {
    text-decoration: line-through;
}

.todo-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.todo-checkbox:hover {
    border-color: var(--success);
}

.todo-checkbox.checked {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.todo-text {
    flex: 1;
    font-size: 0.95rem;
}

.todo-actions {
    display: flex;
    gap: 6px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background: var(--bg-card);
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--accent);
    color: #fff;
}

.btn-icon.delete:hover {
    background: var(--danger);
}

/* ==================== FILES ==================== */
.file-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-primary);
    border-radius: 10px;
    margin-bottom: 8px;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-item:hover {
    background: #e8e8ed;
}

.file-item.active {
    background: var(--accent);
    color: #fff;
}

.file-icon {
    font-size: 1.2rem;
}

.file-name {
    flex: 1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.file-item.active .file-date {
    color: rgba(255,255,255,0.7);
}

.file-editor {
    width: 100%;
    min-height: 300px;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
    background: #fafafa;
}

.file-editor:focus {
    outline: none;
    border-color: var(--accent);
}

/* ==================== TABS ==================== */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 12px;
}

.tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.tab:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.tab.active {
    background: var(--accent);
    color: #fff;
}

.tab-content {
    display: none;
}

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

/* ==================== USERS TABLE ==================== */
.users-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table th,
.users-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.users-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.users-table tr:hover td {
    background: var(--bg-primary);
}

.role-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.role-badge.admin {
    background: var(--accent);
    color: #fff;
}

.role-badge.user {
    background: var(--bg-primary);
    color: var(--text-secondary);
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

.status-badge.active {
    background: #e8f5e9;
    color: var(--success);
}

.status-badge.pending {
    background: #fff3e0;
    color: var(--warning);
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
    display: block;
}

/* ==================== TOAST ==================== */
.toast-container {
    position: fixed;
    bottom: calc(var(--weekbar-height) + 20px);
    right: 24px;
    z-index: 1000;
}

.toast-custom {
    background: var(--accent);
    color: #fff;
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    margin-top: 8px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ==================== MODAL ==================== */
.modal-backdrop-custom {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-backdrop-custom.show {
    display: flex;
}

.modal-custom {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 32px;
    width: 100%;
    max-width: 480px;
    margin: 20px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions button {
    flex: 1;
}

/* ==================== INPUT GROUP ==================== */
.input-group-flex {
    display: flex;
    gap: 10px;
}

.input-group-flex .form-input {
    flex: 1;
    margin-bottom: 0;
}

.input-group-flex .btn-primary-custom {
    width: auto;
    padding: 14px 24px;
}

/* ==================== INVITE LINK ==================== */
.invite-link-box {
    background: var(--bg-primary);
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 16px;
    word-break: break-all;
    font-family: monospace;
    font-size: 0.85rem;
}

.invite-link-box.success {
    background: #e8f5e9;
    border-color: var(--success);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .main-layout {
        flex-direction: column;
    }

    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 576px) {
    .login-card {
        padding: 32px 24px;
    }

    .top-navbar {
        padding: 0 12px;
    }

    .navbar-center {
        display: none;
    }

    .navbar-right {
        gap: 8px;
    }

    #userName {
        display: none;
    }

    .week-days {
        gap: 4px;
    }

    .day-item {
        padding: 8px 4px;
        min-width: 40px;
    }

    .day-number {
        font-size: 1rem;
    }

    .tabs {
        flex-wrap: wrap;
    }
}
