/* ============================================================================
   Fire Safety System Calculator - Main Stylesheet
   Pure CSS - No frameworks, no preprocessors
   ============================================================================ */

/* ============================================================================
   CSS Custom Properties (Design Tokens)
   ============================================================================ */
:root {
    /* Colors */
    --color-primary: #e63946;
    --color-primary-dark: #c1121f;
    --color-primary-light: #fce4e6;
    --color-secondary: #1d3557;
    --color-secondary-light: #457b9d;
    --color-accent: #f77f00;
    --color-success: #2a9d8f;
    --color-warning: #e9c46a;
    --color-danger: #e63946;
    --color-info: #457b9d;

    /* Neutrals */
    --color-white: #ffffff;
    --color-bg: #f8f9fa;
    --color-bg-card: #ffffff;
    --color-border: #dee2e6;
    --color-text: #212529;
    --color-text-secondary: #6c757d;
    --color-text-muted: #adb5bd;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Typography */
    --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Courier New', Courier, monospace;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 2rem;
    --font-size-3xl: 2.5rem;

    /* Borders & Shadows */
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --border-radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    /* Transitions */
    --transition: all 0.2s ease;
}

/* ============================================================================
   Reset & Base Styles
   ============================================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--color-primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

ul, ol {
    list-style: none;
}

/* ============================================================================
   Layout
   ============================================================================ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.main-content {
    flex: 1;
    padding: var(--space-xl) 0;
}

.hidden {
    display: none !important;
}

.inline-form {
    display: inline;
}

/* ============================================================================
   Navbar
   ============================================================================ */
.navbar {
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-sm) 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.navbar-brand {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    white-space: nowrap;
}

.navbar-brand:hover {
    color: var(--color-primary);
}

.brand-icon {
    font-size: 1.5rem;
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.navbar-links {
    display: flex;
    gap: var(--space-md);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.nav-link {
    color: var(--color-text-secondary);
    font-weight: 500;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--border-radius-sm);
}

.nav-link:hover {
    color: var(--color-primary);
    background: var(--color-primary-light);
}

.nav-user {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

.navbar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-sm);
    flex-direction: column;
    gap: 4px;
}

.navbar-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--color-text);
    transition: var(--transition);
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    gap: 2px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}

.lang-btn {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    background: var(--color-white);
}

.lang-btn.active {
    background: var(--color-secondary);
    color: var(--color-white);
}

.lang-btn:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

/* ============================================================================
   Buttons
   ============================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: 0.625rem 1.25rem;
    font-size: var(--font-size-base);
    font-weight: 600;
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    font-family: var(--font-family);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-white);
    border-color: var(--color-primary);
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    color: var(--color-white);
}

.btn-outline {
    background: transparent;
    color: var(--color-secondary);
    border-color: var(--color-border);
}

.btn-outline:hover {
    border-color: var(--color-secondary);
    color: var(--color-secondary);
}

.btn-warning {
    background: var(--color-accent);
    color: var(--color-white);
    border-color: var(--color-accent);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: var(--font-size-sm);
}

.btn-lg {
    padding: 0.875rem 2rem;
    font-size: var(--font-size-lg);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ============================================================================
   Forms
   ============================================================================ */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-xs);
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    background: var(--color-white);
    transition: var(--transition);
    color: var(--color-text);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    appearance: auto;
}

.form-row {
    display: flex;
    gap: var(--space-md);
}

.form-half {
    flex: 1;
}

.form-hint {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
}

.form-inline-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    align-items: end;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
}

/* ============================================================================
   Alerts
   ============================================================================ */
.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--border-radius);
    margin-bottom: var(--space-lg);
    font-size: var(--font-size-sm);
}

.alert ul {
    margin-top: var(--space-xs);
    padding-left: var(--space-lg);
    list-style: disc;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* ============================================================================
   Badges
   ============================================================================ */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }

/* ============================================================================
   Tables
   ============================================================================ */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table th,
.table td {
    padding: 0.875rem var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.table th {
    background: var(--color-bg);
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

.table .total-row {
    background: var(--color-bg);
    font-size: var(--font-size-lg);
}

.text-right { text-align: right; }
.text-bold { font-weight: 700; }

.actions-cell {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

/* ============================================================================
   Cards & Sections
   ============================================================================ */
.section {
    margin-bottom: var(--space-2xl);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.section-header h2 {
    font-size: var(--font-size-xl);
    color: var(--color-secondary);
}

/* ============================================================================
   Stats Grid
   ============================================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-2xl);
}

.stat-card {
    background: var(--color-white);
    padding: var(--space-xl);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    text-align: center;
    border: 1px solid var(--color-border);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-number {
    font-size: var(--font-size-2xl);
    font-weight: 800;
    color: var(--color-secondary);
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-top: var(--space-xs);
}

.stat-card-highlight {
    border-color: var(--color-accent);
}

.stat-card-highlight .stat-number {
    color: var(--color-accent);
}

.stat-card-premium {
    border-color: var(--color-success);
    background: linear-gradient(135deg, #f0fff0, var(--color-white));
}

.stat-card-premium .stat-number {
    color: var(--color-success);
}

/* ============================================================================
   Components Grid
   ============================================================================ */
.components-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-lg);
}

.component-card {
    background: var(--color-white);
    padding: var(--space-xl);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    text-align: center;
    border: 1px solid var(--color-border);
    transition: var(--transition);
}

.component-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}

.component-icon {
    font-size: 2rem;
    margin-bottom: var(--space-sm);
}

.component-count {
    font-size: var(--font-size-2xl);
    font-weight: 800;
    color: var(--color-primary);
}

.component-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-top: var(--space-xs);
}

/* ============================================================================
   Auth Pages
   ============================================================================ */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: var(--space-xl) 0;
}

.auth-card {
    background: var(--color-white);
    padding: var(--space-2xl);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
}

.auth-card-wide {
    max-width: 580px;
}

.auth-title {
    text-align: center;
    margin-bottom: var(--space-xl);
    color: var(--color-secondary);
    font-size: var(--font-size-2xl);
}

.auth-footer {
    text-align: center;
    margin-top: var(--space-lg);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

/* ============================================================================
   Dashboard
   ============================================================================ */
.page-header {
    margin-bottom: var(--space-xl);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: var(--font-size-2xl);
    color: var(--color-secondary);
}

.page-header p {
    color: var(--color-text-secondary);
}

.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    background: var(--color-white);
    border-radius: var(--border-radius-lg);
    border: 2px dashed var(--color-border);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
}

.empty-state p {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-lg);
}

/* ============================================================================
   Upload Page
   ============================================================================ */
.upload-area {
    border: 3px dashed var(--color-border);
    border-radius: var(--border-radius-lg);
    padding: var(--space-2xl);
    text-align: center;
    background: var(--color-white);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: var(--space-xl);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: var(--space-md);
}

.upload-text {
    font-size: var(--font-size-lg);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-sm);
}

.upload-hint {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-lg);
}

/* Progress Bar */
.upload-progress {
    margin-bottom: var(--space-xl);
}

.progress-bar {
    height: 8px;
    background: var(--color-bg);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

.progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

/* ============================================================================
   Drawing Detail & Calculation
   ============================================================================ */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: var(--space-xl);
    margin-bottom: var(--space-xl);
}

.drawing-preview {
    background: var(--color-white);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.preview-image {
    width: 100%;
    display: block;
}

.preview-placeholder {
    padding: var(--space-2xl);
    text-align: center;
    color: var(--color-text-secondary);
}

.file-icon.large {
    font-size: 4rem;
}

.info-card {
    background: var(--color-white);
    padding: var(--space-lg);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-lg);
}

.info-card h3 {
    margin-bottom: var(--space-md);
    color: var(--color-secondary);
}

.info-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-sm) var(--space-md);
}

.info-list dt {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.info-list dd {
    font-size: var(--font-size-sm);
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Brand Selector */
.brand-selector {
    display: flex;
    gap: var(--space-md);
    align-items: end;
    flex-wrap: wrap;
}

.brand-selector .form-control {
    max-width: 350px;
}

/* ============================================================================
   Spinner
   ============================================================================ */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto var(--space-md);
}

.spinner.large {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

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

.processing-indicator {
    text-align: center;
    padding: var(--space-lg);
}

.analysis-progress {
    text-align: center;
    padding: var(--space-2xl);
}

/* ============================================================================
   Overlay Container (Premium coordinate feature)
   ============================================================================ */
.overlay-container {
    position: relative;
    display: inline-block;
    width: 100%;
}

.overlay-image {
    width: 100%;
    display: block;
}

.overlay-marker {
    position: absolute;
    width: 24px;
    height: 24px;
    background: var(--color-primary);
    border: 2px solid var(--color-white);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    font-size: 10px;
    color: var(--color-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    z-index: 10;
}

.overlay-marker:hover::after {
    content: attr(data-label);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-secondary);
    color: var(--color-white);
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
    font-size: 11px;
    white-space: nowrap;
    margin-bottom: 4px;
}

/* ============================================================================
   Hero Section
   ============================================================================ */
.hero {
    text-align: center;
    padding: var(--space-2xl) 0;
    background: linear-gradient(135deg, var(--color-secondary), var(--color-secondary-light));
    border-radius: var(--border-radius-lg);
    color: var(--color-white);
    margin-bottom: var(--space-2xl);
}

.hero h1 {
    font-size: var(--font-size-3xl);
    margin-bottom: var(--space-md);
}

.hero-subtitle {
    font-size: var(--font-size-lg);
    opacity: 0.9;
    margin-bottom: var(--space-sm);
}

.hero-description {
    max-width: 600px;
    margin: 0 auto var(--space-xl);
    opacity: 0.85;
}

.hero-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.hero-actions .btn-outline {
    border-color: var(--color-white);
    color: var(--color-white);
}

.hero-actions .btn-outline:hover {
    background: rgba(255,255,255,0.15);
}

/* ============================================================================
   Features Section
   ============================================================================ */
.features-section {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.features-section h2 {
    font-size: var(--font-size-2xl);
    color: var(--color-secondary);
    margin-bottom: var(--space-xl);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-lg);
}

.feature-card {
    background: var(--color-white);
    padding: var(--space-xl);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.feature-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-md);
}

.feature-card h3 {
    margin-bottom: var(--space-sm);
    color: var(--color-secondary);
}

.feature-card p {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

/* ============================================================================
   Upgrade Banner
   ============================================================================ */
.upgrade-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-xl);
    background: linear-gradient(135deg, #fff3cd, #ffeeba);
    border: 1px solid #ffc107;
    border-radius: var(--border-radius-lg);
    margin-top: var(--space-xl);
}

.upgrade-content h3 {
    color: var(--color-secondary);
    margin-bottom: var(--space-xs);
}

.upgrade-content p {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

/* Premium Notice */
.premium-notice {
    text-align: center;
    padding: var(--space-2xl);
    background: var(--color-bg);
    border: 2px dashed var(--color-border);
    border-radius: var(--border-radius-lg);
    margin-top: var(--space-xl);
}

.premium-notice h3 {
    color: var(--color-secondary);
    margin-bottom: var(--space-sm);
}

.premium-notice p {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-lg);
}

/* Notes Box */
.notes-box {
    background: var(--color-bg);
    padding: var(--space-lg);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--color-info);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

/* ============================================================================
   Error Pages
   ============================================================================ */
.error-page {
    text-align: center;
    padding: var(--space-2xl) 0;
}

.error-page h1 {
    font-size: 6rem;
    color: var(--color-primary);
    margin-bottom: var(--space-md);
}

.error-page p {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-lg);
    font-size: var(--font-size-lg);
}

/* ============================================================================
   CMS Pages
   ============================================================================ */
.cms-page {
    max-width: 800px;
    margin: 0 auto;
}

.cms-page h1 {
    color: var(--color-secondary);
    margin-bottom: var(--space-xl);
}

.cms-content {
    line-height: 1.8;
    color: var(--color-text-secondary);
}

.cms-edit-section {
    background: var(--color-white);
    padding: var(--space-lg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-lg);
}

/* ============================================================================
   Admin Pages
   ============================================================================ */
.admin-nav {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-xl);
    flex-wrap: wrap;
}

/* ============================================================================
   Footer
   ============================================================================ */
.footer {
    background: var(--color-secondary);
    color: rgba(255, 255, 255, 0.7);
    padding: var(--space-lg) 0;
    text-align: center;
    font-size: var(--font-size-sm);
    margin-top: auto;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */
@media (max-width: 768px) {
    .navbar-toggle {
        display: flex;
    }

    .navbar-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--color-white);
        border-top: 1px solid var(--color-border);
        padding: var(--space-md);
        flex-direction: column;
        box-shadow: var(--shadow-md);
    }

    .navbar-menu.active {
        display: flex;
    }

    .navbar-links {
        flex-direction: column;
    }

    .navbar-actions {
        flex-wrap: wrap;
    }

    .form-row {
        flex-direction: column;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .upgrade-banner {
        flex-direction: column;
        text-align: center;
    }

    .brand-selector {
        flex-direction: column;
    }

    .brand-selector .form-control {
        max-width: 100%;
    }

    .hero h1 {
        font-size: var(--font-size-2xl);
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .components-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================================
   Enhanced UI/UX - Animations, Transitions & Visual Polish
   ============================================================================ */

/* Smooth page load fade-in */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-content {
    animation: fadeInUp 0.4s ease-out;
}

/* Focus ring for keyboard accessibility */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--border-radius-sm);
}

/* Smooth alert appearance and dismissal */
@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-8px); }
}

.alert {
    animation: slideInDown 0.3s ease-out;
    position: relative;
    padding-right: 2.5rem;
}

.alert-dismiss {
    position: absolute;
    top: 50%;
    right: var(--space-md);
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    line-height: 1;
    padding: 0;
}

.alert-dismiss:hover {
    opacity: 1;
}

/* Toast notification container */
.toast-container {
    position: fixed;
    top: 80px;
    right: var(--space-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    max-width: 400px;
}

.toast {
    background: var(--color-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    animation: slideInRight 0.3s ease-out;
    border-left: 4px solid var(--color-success);
}

.toast-error {
    border-left-color: var(--color-danger);
}

.toast-warning {
    border-left-color: var(--color-accent);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-message {
    font-size: var(--font-size-sm);
    color: var(--color-text);
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--color-text-muted);
    padding: 0;
    flex-shrink: 0;
}

.toast-close:hover {
    color: var(--color-text);
}

/* Button loading state */
.btn-loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--color-white);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-outline.btn-loading::after {
    border-color: rgba(0, 0, 0, 0.15);
    border-top-color: var(--color-secondary);
}

/* Enhanced form controls */
.form-control {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.form-control::placeholder {
    color: var(--color-text-muted);
}

.form-control:hover:not(:focus) {
    border-color: var(--color-text-muted);
}

/* Form validation visual feedback */
.form-control.is-valid {
    border-color: var(--color-success);
}

.form-control.is-valid:focus {
    box-shadow: 0 0 0 3px rgba(42, 157, 143, 0.15);
}

.form-control.is-invalid {
    border-color: var(--color-danger);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-error {
    color: var(--color-danger);
    font-size: 0.8rem;
    margin-top: var(--space-xs);
    display: none;
}

.form-control.is-invalid + .form-error {
    display: block;
}

/* Password strength indicator */
.password-strength {
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    margin-top: var(--space-xs);
    overflow: hidden;
}

.password-strength-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease, background-color 0.3s ease;
    width: 0%;
}

.password-strength-bar.weak { width: 25%; background: var(--color-danger); }
.password-strength-bar.fair { width: 50%; background: var(--color-accent); }
.password-strength-bar.good { width: 75%; background: var(--color-warning); }
.password-strength-bar.strong { width: 100%; background: var(--color-success); }

/* Enhanced upload area with pulse animation */
.upload-area {
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, var(--color-primary-light) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.upload-area:hover::before,
.upload-area.drag-over::before {
    opacity: 1;
}

.upload-area.drag-over {
    transform: scale(1.01);
    border-color: var(--color-primary);
}

/* File name preview after selection */
.file-preview {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--color-bg);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--border-radius);
    margin-top: var(--space-md);
}

.file-preview-icon {
    font-size: 1.5rem;
}

.file-preview-info {
    flex: 1;
}

.file-preview-name {
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.file-preview-size {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.file-preview-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--color-text-muted);
    padding: var(--space-xs);
}

.file-preview-remove:hover {
    color: var(--color-danger);
}

/* Animated progress bar with shimmer */
.progress-fill {
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-dark), var(--color-primary));
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Step indicator for multi-step processes */
.steps {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: var(--space-xl);
    position: relative;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex: 1;
    max-width: 200px;
}

.step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-border);
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-size-sm);
    position: relative;
    z-index: 2;
    transition: var(--transition);
}

.step.active .step-circle {
    background: var(--color-primary);
    color: var(--color-white);
    box-shadow: 0 0 0 4px var(--color-primary-light);
}

.step.completed .step-circle {
    background: var(--color-success);
    color: var(--color-white);
}

.step-label {
    margin-top: var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    text-align: center;
}

.step.active .step-label {
    color: var(--color-primary);
    font-weight: 600;
}

.step.completed .step-label {
    color: var(--color-success);
}

.step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 20px;
    left: calc(50% + 24px);
    width: calc(100% - 48px);
    height: 2px;
    background: var(--color-border);
    z-index: 1;
}

.step.completed:not(:last-child)::after {
    background: var(--color-success);
}

/* Card hover ripple effect */
.stat-card,
.component-card,
.feature-card {
    position: relative;
    overflow: hidden;
}

.stat-card::after,
.component-card::after,
.feature-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.4) 50%, transparent 60%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
    pointer-events: none;
}

.stat-card:hover::after,
.component-card:hover::after,
.feature-card:hover::after {
    transform: translateX(100%);
}

/* Enhanced table row transitions */
.table tbody tr {
    transition: background-color 0.15s ease;
}

/* Skeleton loading placeholder */
.skeleton {
    background: linear-gradient(90deg, var(--color-bg) 25%, #e8e8e8 50%, var(--color-bg) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--border-radius-sm);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 14px;
    width: 80%;
    margin-bottom: var(--space-sm);
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--space-md);
}

.skeleton-card {
    height: 120px;
    width: 100%;
}

/* Tooltip */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: var(--color-secondary);
    color: var(--color-white);
    padding: 6px 10px;
    border-radius: var(--border-radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 50;
}

[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* Smooth scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-secondary);
}

/* Selection color */
::selection {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

/* Print styles */
@media print {
    .navbar, .footer, .btn, .upload-area, .brand-selector, .admin-nav {
        display: none !important;
    }
    .main-content {
        padding: 0;
    }
    body {
        background: white;
    }
}

/* ============================================================================
   Projects
   ============================================================================ */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-lg);
}

.project-card {
    background: var(--color-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    padding: var(--space-lg);
    transition: var(--transition);
}

.project-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.project-type-badge {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    background: var(--color-bg);
    padding: 2px 8px;
    border-radius: var(--border-radius-sm);
}

.project-card-title {
    margin-bottom: var(--space-xs);
}

.project-card-title a {
    color: var(--color-secondary);
    text-decoration: none;
}

.project-card-title a:hover {
    color: var(--color-primary);
}

.project-address {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
}

.project-address-inline {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.project-card-stats {
    display: flex;
    gap: var(--space-lg);
    margin-bottom: var(--space-md);
    padding: var(--space-sm) 0;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.mini-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mini-stat-value {
    font-weight: 700;
    font-size: var(--font-size-lg);
    color: var(--color-secondary);
}

.mini-stat-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.project-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.project-meta {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

/* ============================================================================
   Floors
   ============================================================================ */
.floors-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.floor-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg);
    transition: var(--transition);
}

.floor-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.floor-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.floor-title {
    margin: 0;
    font-size: var(--font-size-base);
    color: var(--color-secondary);
}

.floor-card-body {
    margin-bottom: var(--space-sm);
}

.floor-stats {
    display: flex;
    gap: var(--space-lg);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.floor-upload-area {
    border: 2px dashed var(--color-border);
    border-radius: var(--border-radius);
    padding: var(--space-md);
    text-align: center;
    background: var(--color-bg);
}

.floor-upload-area-large {
    border: 3px dashed var(--color-border);
    border-radius: var(--border-radius-lg);
    padding: var(--space-2xl);
    text-align: center;
    background: var(--color-white);
    cursor: pointer;
    transition: var(--transition);
}

.floor-upload-area-large:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.floor-drawing-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.floor-card-actions {
    display: flex;
    gap: var(--space-sm);
}

.section-description {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-lg);
}

/* ============================================================================
   Drawing Viewer & Component Placement
   ============================================================================ */
.drawing-viewer {
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    background: #f8f8f8;
}

.drawing-canvas-wrapper {
    position: relative;
    min-height: 400px;
}

.drawing-base-image {
    width: 100%;
    display: block;
}

.drawing-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    min-height: 400px;
    color: var(--color-text-secondary);
}

.dxf-svg-container {
    width: 100%;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dxf-svg-container svg {
    max-width: 100%;
    height: auto;
}

.placement-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

.placement-marker {
    position: absolute;
    width: 26px;
    height: 26px;
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    font-size: 11px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    z-index: 11;
    transition: transform 0.15s ease;
}

.placement-marker:hover {
    transform: translate(-50%, -50%) scale(1.3);
    z-index: 12;
}

/* Placement Toolbar */
.placement-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    flex-wrap: wrap;
    border-bottom: none;
}

.toolbar-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-right: var(--space-xs);
}

.tool-btn {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--color-text);
}

.tool-btn:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.tool-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.tool-btn-action {
    background: var(--color-success);
    color: white;
    border-color: var(--color-success);
}

.tool-btn-action:hover {
    background: #1e8a5e;
    border-color: #1e8a5e;
}

.tool-btn-danger {
    color: var(--color-danger);
    border-color: var(--color-danger);
}

.tool-btn-danger:hover {
    background: var(--color-danger);
    color: white;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: var(--color-border);
    margin: 0 var(--space-xs);
}

/* Legend */
.legend-grid {
    display: flex;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.legend-marker {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.marker-smoke_sensor      { background: #e74c3c; }
.marker-manual_call_point { background: #c0392b; }
.marker-exit_sign         { background: #27ae60; }
.marker-emergency_light   { background: #f39c12; }
.marker-siren             { background: #8e44ad; }
.marker-fire_panel        { background: #2980b9; }
.marker-exit_point        { background: #16a085; }

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

/* Form sections for project create */
.project-form .form-section {
    background: var(--color-white);
    padding: var(--space-xl);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-lg);
}

.project-form .form-section h3 {
    color: var(--color-secondary);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-border);
}

.form-hint {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
}

.required {
    color: var(--color-danger);
}

.loading-text {
    color: var(--color-text-muted);
    font-style: italic;
}

.stats-grid-small {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--space-md);
}

.stats-grid-small .stat-card {
    padding: var(--space-md);
}

.stats-grid-small .stat-number {
    font-size: var(--font-size-xl);
}

/* Badge info variant */
.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-secondary {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

/* Responsive adjustments for projects */
@media (max-width: 768px) {
    .projects-grid {
        grid-template-columns: 1fr;
    }

    .placement-toolbar {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .floor-stats {
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .legend-grid {
        gap: var(--space-sm);
    }

    .quick-actions {
        flex-direction: column;
    }
}
