/* =============================================
   PulseGuard Cloud — Standalone Portal Styles
   Design system ported from PulseBIM Cloud
   ============================================= */

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Brand */
    --guard:        #F97316;
    --guard-hover:  #ea580c;
    --guard-light:  #FFF7ED;
    --guard-subtle: rgba(249,115,22,0.06);

    /* Palette */
    --blue:         #0052FF;
    --blue-hover:   #0045D9;
    --blue-light:   #E8F0FE;
    --blue-subtle:  rgba(0,82,255,0.04);
    --green:        #10b981;
    --red:          #ef4444;
    --amber:        #f59e0b;
    --purple:       #8b5cf6;
    --cyan:         #06b6d4;
    --danger:       #ef4444;
    --success:      #10b981;

    /* Surfaces */
    --bg-page:      #F5F6FA;
    --bg-card:      #FFFFFF;
    --bg-secondary: #F8F9FC;
    --bg-hover:     #F1F3F9;
    --bg-tabs:      #FFFFFF;

    /* Text */
    --text:           #0F172A;
    --text-secondary: #64748B;
    --text-muted:     #94A3B8;

    /* Borders */
    --border:       #E2E8F0;
    --border-light: #F1F5F9;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
    --shadow-md: 0 4px 12px rgba(15,23,42,0.06);
    --shadow-lg: 0 12px 40px rgba(15,23,42,0.08);

    /* Radii */
    --radius:    12px;
    --radius-sm: 8px;

    /* Layout */
    --header-h: 56px;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-page);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.view { display: none; }
.view.active { display: flex; flex-direction: column; min-height: 100vh; }

/* ===== LOGIN (Dark Enterprise) ===== */
#view-login .login-inner {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; flex-direction: column; width: 100%;
    background: linear-gradient(135deg, #060b18 0%, #0a1628 40%, #0d1f3c 70%, #060b18 100%);
}
.login-card {
    background: #0c1425; border: 1px solid #172036;
    border-radius: 20px; padding: 48px; width: 420px; max-width: 90vw;
    box-shadow: 0 0 80px rgba(249,115,22,0.06), 0 0 0 1px rgba(255,255,255,0.02);
}
.login-brand { text-align: center; margin-bottom: 32px; }
.login-brand .icon { margin: 0 auto 16px; width: 72px; height: 72px; }
.login-brand .icon img { width: 100%; height: 100%; object-fit: contain; }
.login-brand h1 { font-size: 28px; font-weight: 700; color: #fff; }
.login-brand h1 span { color: #f97316; }
.login-brand .sub { color: #64748b; font-size: 12px; margin-top: 4px; letter-spacing: 3px; text-transform: uppercase; }
.login-brand p { color: #64748b; margin-top: 12px; font-size: 14px; }

.login-form .form-group { margin-bottom: 16px; }
.login-form .form-group label {
    display: block; font-size: 12px; font-weight: 600; color: #64748b;
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}
.login-form .form-group input {
    width: 100%; padding: 12px 16px; background: #080f1e; border: 1px solid #172036;
    border-radius: 10px; color: #e2e8f0; font-size: 14px; font-family: inherit; transition: border-color 0.2s;
}
.login-form .form-group input:focus { outline: none; border-color: #f97316; box-shadow: 0 0 0 3px rgba(249,115,22,0.12); }
.login-form .form-group input::placeholder { color: #475569; }

.login-btn {
    padding: 12px 24px; border: none; border-radius: 10px; font-family: inherit;
    font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: linear-gradient(135deg, #c2410c, #f97316); color: #fff; width: 100%;
}
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(249,115,22,0.25); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.cf-turnstile { margin-bottom: 16px; }

.login-error {
    background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.25);
    color: #fca5a5; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 12px;
}
.login-footer { text-align: center; margin-top: 24px; font-size: 12px; color: #64748b; }
.login-footer a { color: #f97316; text-decoration: none; }
.login-footer a:hover { text-decoration: underline; }

.corp-footer { text-align: center; padding: 32px 24px; color: #64748b; font-size: 12px; }
.corp-footer a { color: #64748b; text-decoration: none; }
.corp-footer a:hover { color: #94a3b8; }

/* ===== HEADER ===== */
.app-header {
    height: var(--header-h);
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-logo {
    display: flex; align-items: center; gap: 10px;
}
.header-logo img { width: 32px; height: 32px; object-fit: contain; }
.header-brand {
    font-size: 17px; font-weight: 700; color: #fff; letter-spacing: -0.3px;
}
.header-brand strong { color: #f97316; }

.header-right { display: flex; align-items: center; gap: 10px; }
.header-user {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 12px 4px 4px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 50px; cursor: default;
}
.header-avatar {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #c2410c, #f97316);
    border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700;
}
.header-user-info { display: flex; flex-direction: column; }
.header-user-name { font-size: 12px; font-weight: 600; color: #fff; }
.header-user-email { font-size: 10px; color: rgba(255,255,255,0.5); }

.header-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.7); font-size: 14px; cursor: pointer;
    border-radius: 8px; transition: all 0.15s;
}
.header-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ===== MAIN CONTENT ===== */
.app-content {
    flex: 1; padding: 28px 32px;
    max-width: 1200px; width: 100%; margin: 0 auto;
    animation: fadeUp 0.3s ease;
}

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.3; }
.page-header .subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* ===== KPI CARDS ===== */
.kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.kpi-card {
    background: var(--bg-card); border: 1px solid var(--border-light);
    border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow-sm); transition: box-shadow 0.2s, transform 0.15s;
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.kpi-label {
    font-size: 12px; font-weight: 500; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px;
}
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.2; }

.kpi-icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px; font-size: 16px; float: right;
}
.kpi-icon.orange { background: var(--guard-light); color: var(--guard); }
.kpi-icon.green { background: #D1FAE5; color: var(--green); }
.kpi-icon.blue { background: var(--blue-light); color: var(--blue); }
.kpi-icon.purple { background: #EDE9FE; color: var(--purple); }

/* ===== DATA TABLE ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead th {
    text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted); padding: 12px 16px;
    border-bottom: 1px solid var(--border); background: var(--bg-secondary);
}
.data-table tbody td {
    padding: 14px 16px; border-bottom: 1px solid var(--border-light);
    color: var(--text); vertical-align: middle;
}
.data-table tbody tr { cursor: pointer; transition: background 0.15s, box-shadow 0.15s; position: relative; }
.data-table tbody tr:hover { background: var(--guard-subtle); box-shadow: inset 3px 0 0 0 var(--guard); }
.data-table tbody tr:active { background: var(--guard-light); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; font-size: 12px; font-weight: 600; border-radius: 20px;
}

/* ===== BUTTONS ===== */
.btn-primary {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; font-family: inherit; font-size: 13px; font-weight: 600;
    background: var(--guard); color: #fff; border: none;
    border-radius: var(--radius-sm); cursor: pointer; transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--guard-hover); }
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; font-family: inherit; font-size: 13px; font-weight: 500;
    background: none; color: var(--text-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-sm); cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.btn-ghost:hover { background: var(--bg-hover); border-color: var(--text-muted); }

.btn-icon {
    width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    background: none; border: 1px solid var(--border-light);
    border-radius: 6px; cursor: pointer; font-size: 13px;
    color: var(--text-secondary); transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg-hover); border-color: var(--border); }

/* ===== TOAST ===== */
.toast-container {
    position: fixed; top: calc(var(--header-h) + 12px); right: 20px;
    z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 18px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    font-size: 13px; font-weight: 500; color: var(--text);
    animation: slideIn 0.25s ease; max-width: 400px;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--guard); }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }

.kpi-card { animation: cardIn 0.35s ease both; }
.kpi-card:nth-child(1) { animation-delay: 0.02s; }
.kpi-card:nth-child(2) { animation-delay: 0.06s; }
.kpi-card:nth-child(3) { animation-delay: 0.10s; }
@keyframes cardIn { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

.data-table tbody tr { animation: rowIn 0.25s ease both; }
.data-table tbody tr:nth-child(1) { animation-delay: 0.04s; }
.data-table tbody tr:nth-child(2) { animation-delay: 0.08s; }
.data-table tbody tr:nth-child(3) { animation-delay: 0.12s; }
.data-table tbody tr:nth-child(4) { animation-delay: 0.16s; }
.data-table tbody tr:nth-child(5) { animation-delay: 0.20s; }
@keyframes rowIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .app-content { padding: 20px 16px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .header-user-info { display: none; }
}
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
}