/* 
    iWatchU Main Stylesheet
    Consolidated from portal, admin, features, and index pages.
    Part of MVC Segregation (View Layer)
*/

:root {
    --primary: #ff4d00;
    --secondary: #00f2ff;
    --bg-base: #030303;
    --bg-dark: #09090b;
    --bg-surface: #111111;
    --bg-surface-alt: #18181b;
    --bg-elevated: #1a1a1a;
    --text-main: #f8f9fa;
    --text-muted: #a1a1aa;
    --border-subtle: #27272a;
    --border-color: #334155;
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --primary-glow: rgba(255, 77, 0, 0.4);
    --secondary-glow: rgba(0, 242, 255, 0.4);
    --danger-glow: rgba(239, 68, 68, 0.4);
    --warning-glow: rgba(245, 158, 11, 0.4);
    --purple: #a855f7;
    --purple-glow: rgba(168, 85, 247, 0.4);
    --orange: #f97316;
    --orange-glow: rgba(249, 115, 22, 0.4);
}

/* --- Global Resets --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background-color: var(--bg-base); color: var(--text-main); line-height: 1.6; overflow-x: hidden; }
h1, h2, h3, h4, h5, h6 { font-family: 'Space Grotesk', sans-serif; font-weight: 700; letter-spacing: -0.02em; }

/* --- Branding --- */
.logo { font-size: 1.5rem; font-weight: 700; letter-spacing: -1px; font-family: 'Space Grotesk', sans-serif; text-decoration: none; color: var(--text-main); display: flex; align-items: center; gap: 10px; }
.logo span { color: var(--primary); }

/* --- Navigation & Headers --- */
header, nav.main-nav { 
    padding: 20px 5%; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 1px solid var(--border-subtle); 
    background: rgba(3, 3, 3, 0.8); 
    backdrop-filter: blur(10px); 
    position: fixed; 
    width: 100%; 
    top: 0; 
    z-index: 1000; 
}
header .inner, nav.main-nav .inner {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- Buttons --- */
.btn { padding: 12px 24px; font-size: 1rem; font-weight: 600; border-radius: 8px; text-decoration: none; transition: all 0.3s ease; cursor: pointer; border: none; display: inline-flex; align-items: center; justify-content: center; font-family: 'Space Grotesk', sans-serif; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 20px rgba(255, 77, 0, 0.3); }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-secondary { background: rgba(0, 242, 255, 0.1); color: var(--secondary); border: 1px solid var(--secondary); }
.btn-secondary:hover { background: rgba(0, 242, 255, 0.2); }
.btn-outline { background: transparent; color: var(--text-main); border: 2px solid var(--border-subtle); }
.btn-outline:hover { border-color: var(--text-main); }

/* --- Badges --- */
.badge { display: inline-flex; align-items: center; padding: 6px 16px; background: rgba(0, 242, 255, 0.1); color: var(--secondary); border-radius: 50px; font-size: 0.85rem; font-weight: 600; border: 1px solid rgba(0, 242, 255, 0.2); letter-spacing: 1px; }

/* --- Cards --- */
.card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 16px; transition: all 0.3s ease; position: relative; overflow: hidden; }
.card:hover { transform: translateY(-5px); border-color: #333; box-shadow: 0 20px 40px rgba(0,0,0,0.4); }

/* --- Modals --- */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); justify-content: center; align-items: center; z-index: 10000; backdrop-filter: blur(5px); }
.modal-content { background: var(--bg-surface); border: 1px solid var(--border-subtle); padding: 40px; border-radius: 16px; width: 100%; max-width: 500px; box-shadow: 0 20px 50px rgba(0,0,0,0.5); }

/* --- Tables --- */
.table-container { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 12px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 16px 24px; border-bottom: 1px solid var(--border-subtle); }
th { background: var(--bg-elevated); color: var(--text-muted); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 50px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.status-safe { background: rgba(34, 197, 94, 0.1); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.2); }
.status-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }
.status-warning { background: rgba(234, 179, 8, 0.1); color: var(--warning); border: 1px solid rgba(234, 179, 8, 0.2); }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.safe { background: var(--success); }
.dot.danger { background: var(--danger); }
.dot.warning { background: var(--warning); }

/* --- Forms --- */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; color: var(--text-muted); font-size: 0.9rem; }
input, select { width: 100%; padding: 12px; background: var(--bg-elevated); border: 1px solid var(--border-subtle); color: white; border-radius: 8px; font-size: 1rem; outline: none; transition: border-color 0.3s; }
input:focus { border-color: var(--secondary); }

/* --- Portal Specific --- */
.sidebar { width: 250px; border-right: 1px solid var(--border-subtle); background: var(--bg-surface); padding: 30px 20px; display: flex; flex-direction: column; gap: 10px; }
.nav-item { padding: 12px 16px; color: var(--text-muted); text-decoration: none; border-radius: 8px; font-weight: 500; transition: all 0.2s; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.nav-item:hover, .nav-item.active { background: rgba(0, 242, 255, 0.1); color: var(--secondary); }
.content-area { flex: 1; padding: 40px; overflow-y: auto; background: var(--bg-base); }
.page-header { margin-bottom: 30px; display: flex; justify-content: space-between; align-items: flex-end; }

/* --- Stats Grid --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; margin-bottom: 40px; }
.stat-card { background: var(--bg-surface); border: 1px solid var(--border-subtle); padding: 24px; border-radius: 12px; }
.stat-title { color: var(--text-muted); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; display: block; }
.stat-value { font-size: 2.5rem; font-weight: 700; font-family: 'Space Grotesk', sans-serif; }
.stat-value.safe { color: var(--success); }
.stat-value.alert { color: var(--danger); }

/* --- Features / Dictionary Grid --- */
.dictionary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 2rem; padding: 0 5% 100px; max-width: 1400px; margin: 0 auto; }
.threat-card { background: var(--bg-surface-alt); border: 1px solid var(--border-subtle); padding: 0; border-radius: 16px; transition: all 0.3s ease; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.threat-card:hover { transform: translateY(-5px); border-color: #475569; background: #1c1c20; }
.threat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; opacity: 0; transition: opacity 0.3s ease; z-index: 10; }
.threat-card.structural:hover::before { background: var(--danger); opacity: 1; box-shadow: 0 0 20px var(--danger-glow); }
.threat-card.semantic:hover::before { background: var(--primary); opacity: 1; box-shadow: 0 0 20px var(--primary-glow); }
.threat-card.visual:hover::before { background: var(--success); opacity: 1; box-shadow: 0 0 20px rgba(16, 185, 129, 0.4); }
.threat-card.crawler:hover::before { background: var(--orange); opacity: 1; box-shadow: 0 0 20px var(--orange-glow); }
.threat-card.supply:hover::before { background: var(--purple); opacity: 1; box-shadow: 0 0 20px var(--purple-glow); }
.threat-card.infra:hover::before { background: var(--warning); opacity: 1; box-shadow: 0 0 20px var(--warning-glow); }
.threat-card img { width: 100%; height: 200px; object-fit: cover; border-bottom: 1px solid var(--border-color); }
.threat-card .card-content { padding: 2rem; }

/* --- Feature Layouts (Alternating) --- */
.features-wrapper { max-width: 1400px; margin: 0 auto; padding: 50px 5% 100px; }
.feature-row { display: flex; align-items: center; justify-content: space-between; gap: 6%; margin-bottom: 8rem; width: 100%; }
.feature-row.reverse { flex-direction: row-reverse; }
.feature-content { flex: 0 0 50%; max-width: 50%; }
.feature-content h2 { font-size: 2.2rem; margin-bottom: 1.2rem; color: #fff; }
.feature-content p { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.feature-image { flex: 0 0 40%; max-width: 40%; border-radius: 12px; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,0.5); border: 1px solid var(--border-subtle); background: var(--bg-surface); }
.feature-image img { width: 100%; max-width: 100%; height: auto; display: block; transition: transform 0.5s ease; object-fit: cover; }
.feature-image:hover img { transform: scale(1.02); }

@media (max-width: 992px) { 
    .feature-row, .feature-row.reverse { flex-direction: column; text-align: center; gap: 2rem; margin-bottom: 5rem; } 
    .feature-content, .feature-image { max-width: 100%; flex: 1 1 auto; }
}

/* --- Login Box --- */
.login-box { background: var(--bg-surface); padding: 40px; border-radius: 16px; width: 100%; max-width: 400px; text-align: center; border: 1px solid var(--border-subtle); }

/* --- Loading Spinner --- */
#global-loader { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 20000; justify-content: center; align-items: center; flex-direction: column; gap: 20px; backdrop-filter: blur(3px); }
.spinner { width: 50px; height: 50px; border: 3px solid rgba(0, 242, 255, 0.1); border-top: 3px solid var(--secondary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loader-text { color: var(--secondary); font-family: 'Space Grotesk', sans-serif; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; font-size: 0.9rem; }

/* --- Layout Utility --- */
.flex-row { display: flex; align-items: center; gap: 20px; }
.text-center { text-align: center; }
.m-b-30 { margin-bottom: 30px; }
.m-b-15 { margin-bottom: 15px; }
.url-cell { font-family: monospace; color: #d4d4d8; }
.layer-tag { background: var(--bg-elevated); padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-family: monospace; }
.error-msg { color: var(--danger); font-size: 0.85rem; margin-bottom: 15px; display: none; }

/* --- Additional Utilities --- */
.p-24 { padding: 24px; }
.m-t-20 { margin-top: 20px; }
.m-b-10 { margin-bottom: 10px; }
.m-b-20 { margin-bottom: 20px; }
.m-b-24 { margin-bottom: 24px; }
.m-b-40 { margin-bottom: 40px; }
.m-b-80 { margin-bottom: 80px; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.align-end { align-items: flex-end; }
.w-100 { width: 100%; }
.max-w-400 { max-width: 400px; }
.max-w-500 { max-width: 500px; }
.max-w-600 { max-width: 600px; }
.max-w-800 { max-width: 800px; }
.font-mono { font-family: monospace; }
.font-bold { font-weight: bold; }
.font-600 { font-weight: 600; }
.font-09 { font-size: 0.9rem; }
.font-08 { font-size: 0.8rem; }
.font-07 { font-size: 0.7rem; }
.opacity-04 { opacity: 0.4; }
.underline { text-decoration: underline; }
.pointer { cursor: pointer; }
.white-pre { white-space: pre-wrap; }
.overflow-y { overflow-y: auto; }

/* --- Dynamic Layer Tags --- */
.layer-basic { background: #333; color: white; }
.layer-advanced { background: var(--secondary); color: black; }
.p-40 { padding: 40px; }

/* --- Missing Structural Classes (Layout Fix) --- */
.main-content { display: flex; flex: 1; overflow: hidden; height: calc(100vh - 80px); margin-top: 80px; }
#dashboard { display: none; width: 100%; height: 100vh; flex-direction: column; overflow: hidden; }
#login-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: radial-gradient(circle at center, #1a1a1a 0%, #030303 100%); display: flex; justify-content: center; align-items: center; z-index: 9999; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.close-btn { background: transparent; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; }
