/* =====================================
   DDM Gantt Chart - modern UI
   ===================================== */

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

:root {
    --bg: #f5f6fa;
    --sidebar-bg: #1a1a1a;
    --sidebar-text: #a1a1aa;
    --sidebar-text-active: #ffffff;
    --sidebar-hover: #2a2a2a;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: #eef0ff;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    --text: #18181b;
    --text-muted: #71717a;
    --text-secondary: #52525b;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    --radius: 10px;
    --radius-lg: 14px;
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 72px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

/* =============== SIDEBAR =============== */

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
    overflow-x: hidden;
}

.sidebar.collapsed { width: var(--sidebar-width-collapsed); }

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #2a2a2a;
    min-height: 76px;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-brand { flex: 1; overflow: hidden; white-space: nowrap; }
.sidebar-brand-name { color: #fff; font-weight: 600; font-size: 15px; line-height: 1.2; }
.sidebar-brand-sub { color: #71717a; font-size: 12px; margin-top: 2px; }

.sidebar.collapsed .sidebar-brand { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 20px 12px; }
.sidebar.collapsed .sidebar-toggle { display: none; }

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: inherit;
}
.sidebar-toggle:hover { background: #2a2a2a; color: #fff; }

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); }
.sidebar-nav a.active { background: var(--accent); color: #fff; }

.sidebar-nav a svg { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar.collapsed .sidebar-nav a span { display: none; }
.sidebar.collapsed .sidebar-nav a { justify-content: center; padding: 10px; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid #2a2a2a;
    font-size: 12px;
    color: var(--sidebar-text);
}

.sidebar-footer .user-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}
.sidebar-footer .user-line::before {
    content: '';
    width: 8px; height: 8px;
    background: #10b981;
    border-radius: 50%;
    flex-shrink: 0;
}
.sidebar-footer .user-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}
.sidebar-footer a {
    color: var(--danger);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}
.sidebar-footer a:hover { color: #fca5a5; }

.sidebar.collapsed .sidebar-footer { padding: 16px 12px; text-align: center; }
.sidebar.collapsed .sidebar-footer .user-email,
.sidebar.collapsed .sidebar-footer .footer-label { display: none; }
.sidebar.collapsed .sidebar-footer .user-line { justify-content: center; }

/* =============== MAIN AREA =============== */
/* Uses body padding-left instead of flex, so it always works */

body.has-sidebar { padding-left: var(--sidebar-width); transition: padding-left 0.2s ease; }
body.has-sidebar.sidebar-collapsed { padding-left: var(--sidebar-width-collapsed); }

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 14px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 60px;
}

.role-badge {
    background: var(--accent-light);
    color: var(--accent);
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.role-badge::before {
    content: '';
    width: 6px; height: 6px;
    background: var(--accent);
    border-radius: 50%;
}

.content {
    padding: 32px;
    max-width: 1200px;
    width: 100%;
}

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.page-header p { color: var(--text-muted); font-size: 14px; }

/* =============== CARDS =============== */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.card .card-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}
.stat-card .stat-value { font-size: 28px; font-weight: 600; color: var(--text); }

/* =============== FORMS =============== */

label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
    font-weight: 500;
}

input[type=text], input[type=email], input[type=password], select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    margin-bottom: 16px;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
textarea { resize: vertical; min-height: 100px; }

button, .btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}
button:hover, .btn:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-small { padding: 6px 12px; font-size: 13px; }

.input-with-button { display: flex; gap: 8px; margin-bottom: 6px; }
.input-with-button input { margin-bottom: 0; }
.input-with-button button { white-space: nowrap; }

.form-help { font-size: 12px; color: var(--text-muted); margin-top: -8px; margin-bottom: 16px; }

/* =============== TABLES =============== */

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
    text-align: left;
    padding: 12px 16px;
    background: #fafafa;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
}
td { padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

.status-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-active { background: #d1fae5; color: #065f46; }
.status-removed { background: #fee2e2; color: #991b1b; }

/* =============== MESSAGES =============== */

.msg {
    padding: 14px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    border-left: 3px solid;
}
.msg-success { background: #ecfdf5; color: #065f46; border-color: var(--success); }
.msg-error { background: #fef2f2; color: #991b1b; border-color: var(--danger); }
.msg-info { background: #eff6ff; color: #1e40af; border-color: #3b82f6; }

.credential-box {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 3px solid var(--success);
}
.credential-box h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.credential-box .cred-row { display: flex; gap: 12px; margin-bottom: 8px; font-size: 14px; }
.credential-box .cred-label { color: var(--text-muted); width: 90px; flex-shrink: 0; }

.temp-pw {
    font-family: "SF Mono", Consolas, Monaco, monospace;
    background: #fef3c7;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 13px;
}

/* =============== LOGIN =============== */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #f5f6fa 0%, #e0e7ff 100%);
}
.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}
.login-logo {
    width: 48px; height: 48px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
}
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card > p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.login-card button { width: 100%; justify-content: center; padding: 12px; }

/* =============== UTILS =============== */

.actions { display: flex; gap: 6px; }
.actions form { display: inline; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.mt-16 { margin-top: 16px; }

/* =============== RESPONSIVE =============== */

@media (max-width: 768px) {
    body.has-sidebar { padding-left: var(--sidebar-width-collapsed); }
    .sidebar { width: var(--sidebar-width-collapsed); }
    .sidebar .sidebar-brand,
    .sidebar .sidebar-nav a span,
    .sidebar .user-email,
    .sidebar .footer-label { display: none; }
    .sidebar .sidebar-header { justify-content: center; padding: 20px 12px; }
    .sidebar .sidebar-toggle { display: none; }
    .sidebar .sidebar-nav a { justify-content: center; padding: 10px; }
    .sidebar-footer { padding: 16px 12px; text-align: center; }
    .sidebar-footer .user-line { justify-content: center; }
    .content { padding: 20px; }
    .topbar { padding: 14px 20px; }
}
