@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    --bg-primary: #090d16;
    --bg-secondary: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.45);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #22d3ee; /* Glowing Cyan */
    --accent-rgb: 34, 211, 238;
    --success: #10b981; /* Emerald */
    --success-rgb: 16, 185, 129;
    --warning: #f59e0b; /* Amber */
    --error: #ef4444; /* Rose */
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(34, 211, 238, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.05) 0px, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    padding: 24px;
}

/* App Container Layout */
.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header Section */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding: 16px;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
}

.logo-section h1 {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 24px;
    background: linear-gradient(135deg, #22d3ee, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.logo-section p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

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

/* API Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    padding: 8px 16px;
    border-radius: 20px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}
.status-dot.active {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
    animation: pulse 2s infinite;
}
.status-dot.inactive {
    background: var(--error);
    box-shadow: 0 0 10px var(--error);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    border: 1px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, #06b6d4, #3b82f6);
    color: #ffffff;
    box-shadow: 0 4px 14px 0 rgba(6, 182, 212, 0.3);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(6, 182, 212, 0.4);
    background: linear-gradient(135deg, #0891b2, #2563eb);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--panel-border);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
    background: var(--error);
    color: #ffffff;
    transform: translateY(-2px);
}

.btn-icon {
    padding: 8px;
    border-radius: 8px;
}

/* Dashboard Grid Layout */
.grid-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
}

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

/* Navigation Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    padding: 24px 16px;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    height: fit-content;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition-speed);
    cursor: pointer;
}
.nav-item:hover, .nav-item.active {
    color: var(--accent);
    background: rgba(34, 211, 238, 0.08);
}
.nav-item.active {
    font-weight: 600;
    border-left: 3px solid var(--accent);
}

/* Content Pages */
.page {
    display: none;
    flex-direction: column;
    gap: 24px;
}
.page.active {
    display: flex;
}

/* Dashboard Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    padding: 24px;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.stat-card.success::before {
    background: linear-gradient(90deg, transparent, var(--success), transparent);
}

.stat-card.error::before {
    background: linear-gradient(90deg, transparent, var(--error), transparent);
}

.stat-title {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    margin: 8px 0;
    font-family: 'Outfit', sans-serif;
}

.stat-icon {
    position: absolute;
    right: 24px;
    bottom: 24px;
    font-size: 32px;
    opacity: 0.15;
    color: var(--text-primary);
}

/* Panels */
.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    padding: 24px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 16px;
}

.panel-title {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

th {
    text-align: left;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.01);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 14px;
    color: var(--text-secondary);
}

tr:hover td {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.01);
}

/* Log Entries */
.logs-container {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 8px;
}

.log-entry {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border-left: 3px solid var(--text-muted);
    font-size: 13.5px;
}

.log-entry.info {
    border-left-color: var(--accent);
}
.log-entry.warn {
    border-left-color: var(--warning);
    background: rgba(245, 158, 11, 0.03);
}
.log-entry.error {
    border-left-color: var(--error);
    background: rgba(239, 104, 104, 0.03);
}

.log-time {
    font-family: monospace;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    margin-top: 2px;
}

.log-msg {
    flex: 1;
    color: var(--text-secondary);
    line-height: 1.4;
    word-break: break-all;
    overflow-wrap: anywhere;
    min-width: 0;
}

/* Manufacturers List */
.manufacturer-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.manufacturer-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 200px;
    box-shadow: var(--card-shadow);
}

.manufacturer-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.manufacturer-email {
    font-size: 13.5px;
    color: var(--accent);
    margin-bottom: 16px;
}

.manufacturer-rules {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
}

.rule-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--text-secondary);
}

.rule-badge.prefix {
    border-color: rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.05);
}

.manufacturer-card-actions {
    display: flex;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 12px;
}

/* Modal Dialogs */
dialog {
    background: rgba(20, 30, 48, 0.95);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    color: var(--text-primary);
    padding: 28px;
    max-width: 580px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}

dialog::backdrop {
    background-color: rgba(9, 13, 22, 0.85);
    backdrop-filter: blur(8px);
}

dialog h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    margin-bottom: 16px;
}

/* Form Styles */
.form-group {
    margin-bottom: 16px;
}

.form-group.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-speed);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.15);
    background: rgba(255, 255, 255, 0.06);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

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

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Rules Creator Section */
.rules-creator {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.rule-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

/* Animations */
@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.spin {
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.badge-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

/* Instructions */
.info-box {
    background: rgba(34, 211, 238, 0.03);
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 20px;
    font-size: 13.5px;
    line-height: 1.45;
}
