/* SPack EdgeView - Custom Dark Theme */

:root {
    --primary-color: #3b82f6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    --dark-bg: #0f172a;
    --card-bg: #1e293b;
    --border-color: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
}

body {
    background-color: var(--dark-bg);
    color: var(--text-primary);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.9rem; /* Slightly smaller base font */
    padding-top: 60px; /* Account for fixed navbar */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Sticky Footer */
main {
    flex: 1 0 auto;
}

.footer {
    flex-shrink: 0;
}

/* Navbar */
.navbar {
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.brand-logo {
    font-size: 1.5rem; /* Reduced from 2rem */
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-subtitle {
    font-size: 0.6rem; /* Reduced from 0.7rem */
    color: var(--text-secondary);
    letter-spacing: 0.5px; /* Reduced from 1px */
}

.nav-link {
    transition: color 0.3s ease;
}

.nav-link:hover {
    color: var(--primary-color) !important;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px; /* Reduced from 12px */
    box-shadow: 0 2px 4px rgba(0,0,0,0.2); /* Reduced shadow */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-1px); /* Reduced from -2px */
    box-shadow: 0 4px 8px rgba(0,0,0,0.3); /* Reduced shadow */
}

.card-header {
    background-color: rgba(255,255,255,0.05);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    padding: 0.75rem 1rem; /* More compact */
    font-size: 0.95rem; /* Slightly smaller */
}

/* KPI Cards */
.kpi-card {
    padding: 1rem; /* Reduced from 1.5rem */
    border-radius: 8px; /* Reduced from 12px */
    background: linear-gradient(135deg, var(--card-bg), rgba(59, 130, 246, 0.1));
    border: 1px solid var(--border-color);
}

.kpi-icon {
    width: 45px; /* Reduced from 60px */
    height: 45px; /* Reduced from 60px */
    border-radius: 8px; /* Reduced from 12px */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem; /* Reduced from 1.8rem */
}

.kpi-value {
    font-size: 1.75rem; /* Reduced from 2.5rem */
    font-weight: 700;
    margin: 0;
    line-height: 1;
}

.kpi-label {
    color: var(--text-secondary);
    font-size: 0.75rem; /* Reduced from 0.9rem */
    margin-top: 0.25rem; /* Reduced from 0.5rem */
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem; /* Reduced from 0.4rem 1rem */
    border-radius: 15px; /* Reduced from 20px */
    font-weight: 600;
    font-size: 0.7rem; /* Reduced from 0.85rem */
    display: inline-block;
}

.status-running {
    background-color: rgba(16, 185, 129, 0.2);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.status-stopped {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.status-warning {
    background-color: rgba(245, 158, 11, 0.2);
    color: var(--warning-color);
    border: 1px solid var(--warning-color);
}

.status-idle {
    background-color: rgba(100, 116, 139, 0.2);
    color: var(--text-secondary);
    border: 1px solid var(--text-secondary);
}

/* Machine Cards */
.machine-card {
    position: relative;
    overflow: hidden;
}

.machine-card .card-body {
    padding: 1rem; /* More compact */
}

.machine-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px; /* Reduced from 4px */
    height: 100%;
    background: var(--primary-color);
}

.machine-card.status-success::before {
    background: var(--success-color);
}

.machine-card.status-danger::before {
    background: var(--danger-color);
}

.machine-card.status-warning::before {
    background: var(--warning-color);
}

/* Alerts */
.alert-item {
    background-color: var(--card-bg);
    border-left: 3px solid; /* Reduced from 4px */
    padding: 0.75rem; /* Reduced from 1rem */
    margin-bottom: 0.5rem; /* Reduced from 0.75rem */
    border-radius: 0 6px 6px 0; /* Reduced from 8px */
    font-size: 0.85rem; /* Smaller text */
}

.alert-item.alert-danger {
    border-left-color: var(--danger-color);
    background-color: rgba(239, 68, 68, 0.1);
}

.alert-item.alert-warning {
    border-left-color: var(--warning-color);
    background-color: rgba(245, 158, 11, 0.1);
}

.alert-item.alert-info {
    border-left-color: var(--info-color);
    background-color: rgba(6, 182, 212, 0.1);
}

/* Progress Bars */
.progress {
    background-color: rgba(255,255,255,0.1);
    height: 8px; /* Reduced from 12px */
    border-radius: 4px; /* Reduced from 6px */
}

.progress-bar {
    border-radius: 4px; /* Reduced from 6px */
    transition: width 0.6s ease;
}

/* OEE Breakdown Bars */
.oee-bar {
    height: 20px; /* Reduced from 24px */
    border-radius: 6px; /* Reduced from 8px */
    position: relative;
    overflow: hidden;
}

.oee-bar-fill {
    height: 100%;
    transition: width 0.6s ease;
    display: flex;
    align-items: center;
    padding-left: 0.5rem; /* Reduced from 0.75rem */
    font-weight: 600;
    font-size: 0.75rem; /* Reduced from 0.9rem */
}

/* Tables */
.table-dark {
    --bs-table-bg: var(--card-bg);
    --bs-table-border-color: var(--border-color);
}

.table-hover tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

/* Buttons */
.btn {
    border-radius: 6px; /* Reduced from 8px */
    font-weight: 600;
    padding: 0.375rem 1rem; /* Reduced from 0.5rem 1.5rem */
    font-size: 0.85rem; /* Smaller buttons */
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.4);
}

/* Charts Container */
.chart-container {
    position: relative;
    height: 280px; /* Reduced from 300px */
    padding: 0.75rem; /* Reduced from 1rem */
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Metric Display */
.metric {
    text-align: center;
    padding: 0.75rem; /* Reduced from 1rem */
}

.metric-value {
    font-size: 1.5rem; /* Reduced from 2rem */
    font-weight: 700;
    margin: 0;
}

.metric-label {
    color: var(--text-secondary);
    font-size: 0.7rem; /* Reduced from 0.85rem */
    margin-top: 0.15rem; /* Reduced from 0.25rem */
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    gap: 1rem; /* Reduced from 1.5rem */
}

/* Container Spacing */
.container-fluid {
    padding-left: 1rem !important; /* Reduced from default */
    padding-right: 1rem !important;
}

/* Row Gaps */
.row.g-4 {
    --bs-gutter-y: 1rem; /* Reduced from 1.5rem */
    --bs-gutter-x: 1rem;
}

/* Headings */
h1 { font-size: 1.75rem; } /* Reduced */
h2 { font-size: 1.5rem; }  /* Reduced */
h3 { font-size: 1.25rem; }  /* Reduced */
h4 { font-size: 1.1rem; }   /* Reduced */
h5 { font-size: 0.95rem; }  /* Reduced */
h6 { font-size: 0.85rem; }  /* Reduced */

/* Icons - Global Reduction */
.bi {
    font-size: 0.9em; /* 10% smaller than parent */
}

/* Responsive - Tablets */
@media (max-width: 992px) {
    body {
        padding-top: 56px;
    }

    .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .kpi-card {
        padding: 0.75rem;
    }

    .kpi-value {
        font-size: 1.5rem;
    }

    .kpi-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    .card-header {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    .machine-card .card-body {
        padding: 0.75rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .table th, .table td {
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    /* Work Orders filter - stack on tablets */
    .row.g-3.align-items-end > div {
        margin-bottom: 0.5rem;
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    body {
        padding-top: 56px;
        font-size: 0.85rem;
    }

    .navbar-brand img {
        height: 28px !important;
    }

    .kpi-value {
        font-size: 1.25rem;
    }

    .kpi-icon {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    .kpi-label {
        font-size: 0.65rem;
    }

    .metric-value {
        font-size: 1.1rem;
    }

    .metric-label {
        font-size: 0.6rem;
    }

    /* Hide less important columns on mobile */
    .table-responsive .hide-mobile {
        display: none;
    }

    .card {
        margin-bottom: 0.75rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    h1 { font-size: 1.25rem; }
    h2 { font-size: 1.1rem; }
    h3 { font-size: 1rem; }
    h5 { font-size: 0.85rem; }

    /* Stack buttons on mobile */
    .d-flex.gap-2 {
        flex-direction: column;
    }

    .d-flex.gap-2 .btn {
        width: 100%;
    }

    /* Work Orders filter - stack on mobile */
    .row.g-3.align-items-end > div {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Navbar adjustments */
    .navbar .d-flex.align-items-center {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }

    .navbar .bg-white.rounded {
        padding: 0.25rem 0.5rem !important;
    }

    .navbar .bg-white.rounded img {
        height: 30px !important;
    }

    /* Footer adjustments */
    .footer {
        padding: 0.5rem 0 !important;
    }

    .footer img {
        height: 24px !important;
    }

    /* Status badges smaller on mobile */
    .status-badge {
        font-size: 0.6rem;
        padding: 0.2rem 0.5rem;
    }

    /* Progress bars thinner on mobile */
    .progress {
        height: 6px;
    }

    /* Nav pills scrollable on mobile */
    .nav-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
    }

    .nav-pills .nav-item {
        flex-shrink: 0;
    }

    .nav-pills .nav-link {
        white-space: nowrap;
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Toast notifications */
    .toast-container {
        width: 100% !important;
        padding: 0.5rem !important;
        margin-top: 60px !important;
    }

    .toast {
        width: 100%;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .container-fluid {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .kpi-card {
        padding: 0.5rem;
    }

    .kpi-value {
        font-size: 1rem;
    }

    .kpi-icon {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
        margin-right: 0.5rem !important;
    }

    .btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .badge {
        font-size: 0.65rem;
    }
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.login-card {
    width: 100%;
    max-width: 450px;
    padding: 2.5rem;
}

.login-logo {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Utility Classes */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
}

.bg-gradient-success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.bg-gradient-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.bg-gradient-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

/* RTL Support */
[dir="rtl"] {
    font-family: 'Segoe UI', Tahoma, 'Arial', sans-serif;
}

[dir="rtl"] .machine-card::before {
    left: auto;
    right: 0;
}

[dir="rtl"] .alert-item {
    border-left: none;
    border-right: 3px solid;
}

[dir="rtl"] .alert-item.alert-danger {
    border-right-color: var(--danger-color);
}

[dir="rtl"] .alert-item.alert-warning {
    border-right-color: var(--warning-color);
}

[dir="rtl"] .alert-item.alert-info {
    border-right-color: var(--info-color);
}

[dir="rtl"] .oee-bar-fill {
    padding-left: 0;
    padding-right: 0.5rem;
}

[dir="rtl"] .kpi-icon {
    margin-right: 0 !important;
    margin-left: 1rem;
}

[dir="rtl"] .me-1 {
    margin-right: 0 !important;
    margin-left: 0.25rem !important;
}

[dir="rtl"] .me-2 {
    margin-right: 0 !important;
    margin-left: 0.5rem !important;
}

[dir="rtl"] .me-3 {
    margin-right: 0 !important;
    margin-left: 1rem !important;
}

[dir="rtl"] .me-4 {
    margin-right: 0 !important;
    margin-left: 1.5rem !important;
}

[dir="rtl"] .ms-1 {
    margin-left: 0 !important;
    margin-right: 0.25rem !important;
}

[dir="rtl"] .ms-2 {
    margin-left: 0 !important;
    margin-right: 0.5rem !important;
}

[dir="rtl"] .text-start {
    text-align: right !important;
}

[dir="rtl"] .text-end {
    text-align: left !important;
}