/* Conservice Design System */
@import url('https://rsms.me/inter/inter.css');

:root {
    --color-gray-50: #f9fafb;
    --color-gray-100: #f2f2f2;
    --color-gray-200: #eaeaea;
    --color-gray-300: #cbcccd;
    --color-gray-400: #aeb3b7;
    --color-gray-500: #8f9aa3;
    --color-gray-600: #6a7f8e;
    --color-gray-700: #496274;
    --color-gray-800: #243746;
    --color-gray-900: #091b29;
    --color-blue-50: #fbfcfe;
    --color-blue-100: #f5fbff;
    --color-blue-200: #ecf3fd;
    --color-blue-600: #4789f0;
    --color-blue-700: #226ce0;
    --color-blue-800: #1a57b7;
    --color-red-50: #fef6f6;
    --color-red-100: #fee2e2;
    --color-red-600: #b91c1c;
    --color-green-100: #d4f7e6;
    --color-green-800: #009950;
    --color-yellow-100: #fef3c7;
}

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

html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100vh;
    background-color: var(--color-gray-50);
    color: var(--color-gray-900);
}

/* ========== Sidebar Layout ========== */
.dashboard {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 220px;
    background-color: var(--color-gray-900);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.logo {
    padding: 20px;
    background-color: white;
}

.logo img {
    height: 32px;
    max-width: 160px;
}

.nav-menu {
    padding: 20px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-section-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--color-gray-600);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 16px 20px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--color-gray-400);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.nav-item:hover {
    background-color: var(--color-gray-800);
    color: white;
}

.nav-item.active {
    background-color: var(--color-blue-700);
    color: white;
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.user-section {
    padding: 16px 20px;
    border-top: 1px solid var(--color-gray-700);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.user-details {
    min-width: 0;
    flex: 1;
}

.user-name-sidebar {
    font-size: 13px;
    color: white;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email-sidebar {
    font-size: 11px;
    color: var(--color-gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    display: block;
    width: 100%;
    padding: 8px;
    background-color: transparent;
    border: 1px solid var(--color-gray-600);
    color: var(--color-gray-400);
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
}

.logout-btn:hover {
    background-color: var(--color-gray-800);
    color: white;
    border-color: var(--color-gray-500);
}

/* ========== Main Content ========== */
.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 32px 40px;
    min-height: 100vh;
}

/* Page welcome header (matches Conservice app style) */
.page-welcome {
    margin-bottom: 28px;
}

.page-welcome h1 {
    font-size: 28px;
    font-weight: 600;
    color: var(--color-gray-900);
    margin: 0 0 4px 0;
}

.page-welcome p {
    color: var(--color-gray-600);
    font-size: 14px;
    margin: 0;
}

.page-header {
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-header h1 {
    font-size: 24px;
    color: var(--color-gray-900);
    margin: 0;
}

.page-header p {
    color: var(--color-gray-600);
    font-size: 14px;
    margin-top: 4px;
}

h1 { font-size: 24px; margin-bottom: 16px; }
h2 { font-size: 18px; margin-bottom: 12px; color: var(--color-gray-800); }

.section { margin-bottom: 32px; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-header h2 { margin-bottom: 0; }

/* ========== Cards ========== */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 14px 20px;
    border-bottom: 2px solid var(--color-blue-700);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.card-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-gray-900);
    margin: 0;
}

.card-body {
    padding: 20px;
}

/* Toolbar row for action buttons above content */
.toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

/* ========== Tables ========== */
.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

/* Standalone tables (not inside a card) get their own shadow */
.main-content > .table,
.card-body > .table {
    border-radius: 0;
    box-shadow: none;
}

.table th, .table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--color-gray-200);
    font-size: 13px;
}

.table th {
    background-color: var(--color-gray-900);
    color: white;
    font-weight: 500;
}

.table tr:hover {
    background-color: var(--color-blue-50);
}

.table tr:last-child td { border-bottom: none; }

.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { background: var(--color-gray-800); }
.sort-arrow { font-size: 0.7rem; }

.actions-cell {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.detail-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: monospace;
    font-size: 12px;
}

.edit-row td { background: var(--color-gray-50); }

/* ========== Buttons ========== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    line-height: 1.4;
}

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-primary { background: var(--color-blue-700); color: white; }
.btn-primary:hover { background: var(--color-blue-800); }

.btn-secondary {
    background: white;
    color: var(--color-gray-700);
    border: 1px solid var(--color-gray-300);
}
.btn-secondary:hover {
    background: var(--color-gray-50);
    border-color: var(--color-gray-400);
}

.btn-danger { background: var(--color-red-600); color: white; }
.btn-danger:hover { background: #991b1b; }

/* ========== Badges ========== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-admin { background: var(--color-blue-200); color: var(--color-blue-700); }
.badge-user { background: var(--color-gray-100); color: var(--color-gray-700); }
.badge-member { background: var(--color-green-100); color: var(--color-green-800); }
.badge-pending { background: var(--color-yellow-100); color: var(--color-gray-800); }
.badge-policy { background: var(--color-gray-100); color: var(--color-gray-700); }
.badge-active { background: var(--color-green-100); color: var(--color-green-800); }
.badge-inactive { background: var(--color-gray-100); color: var(--color-gray-500); }
.badge-action { background: var(--color-blue-200); color: var(--color-blue-700); font-family: monospace; font-size: 11px; }
.badge-approved { background: var(--color-green-100); color: var(--color-green-800); }
.badge-denied { background: var(--color-red-100); color: var(--color-red-600); }

/* ========== Group Cards ========== */
.group-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.group-card {
    background: white;
    border: 1px solid var(--color-gray-200);
    border-radius: 8px;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.2s;
}

.group-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.group-card-compact { padding: 12px 16px; }

.group-info { flex: 1; min-width: 0; }
.group-info h3 { font-size: 14px; font-weight: 600; margin-bottom: 2px; color: var(--color-gray-900); }
.group-email { font-size: 12px; color: var(--color-gray-500); margin-bottom: 4px; }
.group-description { font-size: 13px; color: var(--color-gray-600); margin-bottom: 4px; }
.request-reason { font-size: 12px; color: var(--color-gray-500); font-style: italic; }
.review-note { font-size: 13px; color: var(--color-red-600); margin-bottom: 2px; }
.review-meta { font-size: 12px; color: var(--color-gray-500); }

.retry-form {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding-top: 12px;
    border-top: 1px solid var(--color-gray-200);
    margin-top: 8px;
}

.retry-form .input-sm { flex: 1; min-width: 150px; }

.group-card-denied { border-left: 3px solid var(--color-red-600); flex-wrap: wrap; }

.group-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.join-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ========== Search ========== */
.search-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: white;
    border-bottom: 1px solid var(--color-gray-200);
}

.search-bar .input {
    max-width: 400px;
    padding: 8px 12px;
    font-size: 13px;
}

.search-count { font-size: 12px; color: var(--color-gray-500); white-space: nowrap; }

/* ========== Forms ========== */
.form-card {
    background: white;
    border: 1px solid var(--color-gray-200);
    border-radius: 8px;
    padding: 24px;
    max-width: 600px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    color: var(--color-gray-700);
    margin-bottom: 6px;
    font-weight: 500;
}

.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
}

.input:focus {
    outline: none;
    border-color: var(--color-blue-700);
    box-shadow: 0 0 0 2px var(--color-blue-200);
}

.input-sm {
    padding: 6px 10px;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 13px;
}

.input-sm:focus {
    outline: none;
    border-color: var(--color-blue-700);
    box-shadow: 0 0 0 2px var(--color-blue-200);
}

select.input { appearance: auto; }

.form-help { font-size: 12px; color: var(--color-gray-500); margin-top: 4px; }

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.form-row { margin-bottom: 12px; }
.form-row label { font-size: 13px; font-weight: 500; color: var(--color-gray-700); }

.edit-form { padding: 8px; }

.form-row-inline {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ========== Flash Messages ========== */
.flash {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 14px;
}

.flash-success { background: var(--color-green-100); color: var(--color-green-800); }
.flash-error { background: var(--color-red-100); color: var(--color-red-600); }
.flash-warning { background: var(--color-yellow-100); color: var(--color-gray-800); }
.flash-info { background: var(--color-blue-200); color: var(--color-blue-700); }

/* ========== Filter ========== */
.filter-form { margin-bottom: 16px; }

.result-count {
    font-size: 12px;
    color: var(--color-gray-500);
    margin-bottom: 8px;
}

/* ========== Pagination ========== */
.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    justify-content: center;
}

.page-info { font-size: 13px; color: var(--color-gray-700); }
.pagination select { font-size: 13px; }
.pagination .btn:disabled { opacity: 0.4; cursor: default; }

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    color: var(--color-gray-500);
    padding: 32px;
    font-size: 14px;
}

.empty-state a { color: var(--color-blue-700); }

/* ========== Admin ========== */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 8px;
}

/* ========== Avatar ========== */
.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

.avatar-sm {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-muted { color: var(--color-gray-500); font-size: 13px; }

/* ========== Login Page ========== */
.login-page {
    min-height: 100vh;
    background-image: url('/static/img/login-background.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    position: relative;
}

.login-header {
    position: absolute;
    top: 0;
    left: 0;
    padding: 20px 30px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    border-bottom-right-radius: 8px;
}

.login-header-logo {
    height: 36px;
}

.login-header-subtitle {
    font-size: 12px;
    color: var(--color-gray-500);
    font-style: italic;
}

.login-card {
    position: absolute;
    right: 80px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    width: 380px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.login-title {
    color: var(--color-gray-800);
    font-size: 22px;
    margin: 0 0 8px 0;
    font-weight: 600;
}

.login-subtitle {
    color: var(--color-gray-600);
    margin: 0;
    font-size: 14px;
}

.login-divider {
    height: 3px;
    background: linear-gradient(90deg, #4CAF50 0%, #8BC34A 100%);
    margin: 20px 0;
}

.login-form-section {
    margin-bottom: 30px;
}

.login-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-gray-600);
    margin-bottom: 16px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 24px;
    background-color: white;
    color: var(--color-gray-700);
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

.login-btn:hover {
    background-color: var(--color-gray-50);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    border-color: var(--color-gray-400);
}

.login-footer {
    background-color: var(--color-gray-100);
    margin: 0 -40px -40px -40px;
    padding: 20px 40px;
    text-align: center;
}

.login-footer-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-gray-700);
    margin-bottom: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.login-footer-text {
    font-size: 13px;
    color: var(--color-gray-600);
    margin: 0;
}

/* ========== HTMX ========== */
.htmx-request { opacity: 0.6; pointer-events: none; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }
.htmx-request .refresh-text { display: none; }

@keyframes shimmer {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

.loading-placeholder {
    animation: shimmer 1.5s ease-in-out infinite;
}

/* ========== Mobile ========== */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    background-color: var(--color-gray-900);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    color: white;
}

.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.mobile-overlay.active {
    display: block;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .sidebar {
        left: -260px;
        width: 250px;
        transition: left 0.3s ease;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
        padding-top: 70px;
    }

    .page-header h1 {
        font-size: 20px;
    }

    .group-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .group-actions { width: 100%; }
    .join-form { width: 100%; flex-wrap: wrap; }

    .table th, .table td { padding: 8px 10px; font-size: 12px; }

    .admin-header { flex-direction: column; align-items: flex-start; }

    .login-card {
        position: relative;
        right: auto;
        top: auto;
        transform: none;
        margin: auto;
        margin-top: 100px;
        width: 90%;
        max-width: 380px;
    }

    .login-header {
        width: 100%;
        border-bottom-right-radius: 0;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .login-card {
        width: calc(100% - 32px);
        padding: 24px;
        margin-top: 80px;
    }

    .login-title { font-size: 18px; }

    .login-footer {
        margin: 0 -24px -24px -24px;
        padding: 16px 24px;
    }

    .login-header {
        padding: 12px 16px;
    }

    .login-header-logo { height: 28px; }

    .main-content {
        padding: 12px;
        padding-top: 60px;
    }
}
