/* Portal D - Main Stylesheet */

/* ========== RESET & BASE ========== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #eab308;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #eab308;
    --border: #cbd5e1;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ========== LOGIN PAGE ========== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
}

[data-theme="light"] .login-body {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 50%, #e0e7ff 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 16px;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.login-subtitle {
    color: var(--text-secondary);
    margin-top: 4px;
    font-size: 14px;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.remember-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    user-select: none;
}

.remember-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 20px;
    background: #fff;
    color: #1f2937;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.btn-google:hover {
    background: #f3f4f6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transform: translateY(-1px);
}

.login-divider {
    text-align: center;
    margin-top: 28px;
    position: relative;
}

.login-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.login-divider span {
    background: var(--bg-card);
    padding: 0 16px;
    position: relative;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ========== MAIN PAGE ========== */
.main-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

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

.header-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: rotate(20deg);
}

.header-clock {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 400;
    white-space: nowrap;
}

/* ========== APP GRID ========== */
.app-grid-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 24px;
    max-width: 800px;
    width: 100%;
}

.app-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.app-icon:hover {
    background: var(--bg-hover);
    transform: translateY(-4px);
}

.app-icon:active {
    transform: translateY(0) scale(0.95);
}

.app-icon-circle {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: var(--app-color, var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.app-icon:hover .app-icon-circle {
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    transform: scale(1.05);
}

.app-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1.3;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-icon:hover .app-label {
    color: var(--text-primary);
}

/* ========== FOOTER ========== */
.main-footer {
    padding: 12px 24px;
    text-align: center;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.main-footer p {
    font-size: 11px;
    color: var(--text-muted);
}

/* ========== MODAL ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--danger);
    margin-bottom: 16px;
}

.modal h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.modal p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    gap: 8px;
}

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

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

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    filter: brightness(0.9);
}

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

.btn-danger:hover {
    background: #dc2626;
}

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

.btn-success:hover {
    background: #16a34a;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* ========== APP PAGES (STUBS) ========== */
.app-page {
    min-height: 100vh;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
}

.app-page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.app-page-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
}

.app-page-header h1 {
    font-size: 22px;
    font-weight: 600;
}

.app-page-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.app-placeholder {
    text-align: center;
    color: var(--text-muted);
}

.app-placeholder i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.app-placeholder p {
    font-size: 16px;
}

/* ========== ADMIN PAGE ========== */
.admin-container {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    width: fit-content;
}

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

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

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

.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

.admin-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.admin-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

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

.admin-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(0,0,0,0.05);
}

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

.admin-table tr:hover td {
    background: rgba(255,255,255,0.02);
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-active {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.badge-blocked {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.badge-inactive {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
}

.badge-admin {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

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

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-hover);
}

.user-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-hover);
    border-radius: 12px;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--success);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .main-header {
        flex-direction: column;
        gap: 8px;
        padding: 12px 16px;
    }

    .header-clock {
        font-size: 12px;
    }

    .app-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 16px;
    }

    .app-icon-circle {
        width: 56px;
        height: 56px;
        font-size: 22px;
        border-radius: 16px;
    }

    .app-grid-container {
        padding: 20px 16px;
        align-items: flex-start;
    }

    .admin-container {
        padding: 16px;
    }

    .admin-table th,
    .admin-table td {
        padding: 10px 12px;
    }

    .admin-table .hide-mobile {
        display: none;
    }

    .modal {
        padding: 24px;
    }
}

@media (max-width: 480px) {
    .app-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .app-label {
        font-size: 11px;
    }
}

/* ========== GLOBAL LOADING OVERLAY ========== */
.portald-loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    text-align: center;
    cursor: not-allowed;
    user-select: none;
}

.portald-loading-overlay.active {
    display: flex;
}

.portald-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--accent, #6366f1);
    border-radius: 50%;
    animation: portald-spin 0.8s linear infinite;
}

@keyframes portald-spin {
    to { transform: rotate(360deg); }
}

.portald-loading-text {
    font-size: 15px;
    color: var(--text-primary, #f1f5f9);
    font-weight: 500;
}

body.portald-loading-active * {
    pointer-events: none;
}

.portald-loading-active .portald-loading-overlay,
.portald-loading-active .portald-loading-overlay * {
    pointer-events: auto;
}
