/* ========== RESET & BASE ========== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: #333;
    background: #f0f2f5;
}

a { color: #4fc3f7; text-decoration: none; }
a:hover { color: #0288d1; }

h1 { font-size: 1.6rem; margin-bottom: 0; color: #1a1a2e; font-weight: 600; }
h2 { font-size: 1.15rem; margin-bottom: 0.8rem; color: #555; font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; }
h3 { font-size: 1rem; margin-bottom: 0.4rem; }

/* ========== LOGIN ========== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
}

.login-card {
    background: #fff;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    text-align: center;
    color: #1a1a2e;
    margin-bottom: 0.3rem;
    font-size: 1.8rem;
}

.login-subtitle {
    text-align: center;
    color: #888;
    margin-bottom: 1.8rem;
    font-size: 0.9rem;
}

/* ========== FORMS ========== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
    font-size: 0.85rem;
    color: #555;
}

.form-input, select.form-input {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}

.form-input:focus {
    outline: none;
    border-color: #4fc3f7;
    box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.15);
}

.checkbox-group {
    display: flex;
    gap: 1.2rem;
    flex-wrap: wrap;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: normal;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.2rem;
}

.form-card {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* ========== BUTTONS ========== */
.btn-login {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, #1a1a2e, #302b63);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: opacity 0.2s;
}

.btn-login:hover { opacity: 0.9; }
.btn-login:disabled { opacity: 0.5; cursor: not-allowed; }

.login-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
    text-align: center;
    font-size: 0.75rem;
    color: #9ca3af;
}

.login-footer strong {
    color: #6b7280;
}

.btn-primary {
    padding: 0.5rem 1.2rem;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-primary:hover { background: #302b63; }

.btn-secondary {
    padding: 0.5rem 1.2rem;
    background: #fff;
    color: #555;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-secondary:hover { background: #f5f5f5; }

.btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    border: 1px solid #d0d5dd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-small:hover { background: #f5f5f5; }
.btn-unlock { color: #e67e22; border-color: #e67e22; }
.btn-unlock:hover { background: #fef5e7; }
.btn-toggle { color: #888; }

/* ========== ALERTS ========== */
.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    padding: 0.7rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    border-left: 4px solid #dc2626;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    padding: 0.7rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    border-left: 4px solid #22c55e;
}

/* ========== DATA TABLE ========== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.data-table th {
    background: #1a1a2e;
    color: #fff;
    padding: 0.7rem 0.9rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
}

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

.actions-cell {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

/* ========== BADGES & TAGS ========== */
.role-badge {
    background: #4fc3f7;
    color: #1a1a2e;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.module-tag {
    background: #e3f2fd;
    color: #1565c0;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    margin-right: 0.2rem;
    display: inline-block;
}

.status-active { color: #16a34a; font-weight: 600; }
.status-inactive { color: #9ca3af; font-weight: 500; }
.status-locked { color: #dc2626; font-weight: 600; }

/* ========== DASHBOARD ========== */
.dashboard {
    max-width: 900px;
    margin: 0 auto;
}

.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.dash-header h1 {
    font-size: 1.4rem;
    color: #1a1a2e;
    margin-bottom: 0.2rem;
}

.dash-subtitle {
    font-size: 0.85rem;
    color: #888;
    text-transform: capitalize;
}

/* Stats row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.stat-number {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1;
}

.stat-label {
    font-size: 0.72rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 4px;
}

/* Card grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Dash card with colored left strip */
.dash-card {
    display: flex;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s, transform 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.dash-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.card-strip {
    width: 6px;
    flex-shrink: 0;
}

.card-usa .card-strip { background: linear-gradient(180deg, #1565c0, #42a5f5); }
.card-mx .card-strip { background: linear-gradient(180deg, #2e7d32, #66bb6a); }
.card-trucks .card-strip { background: linear-gradient(180deg, #e65100, #ff9800); }
.card-admin .card-strip { background: linear-gradient(180deg, #5e35b1, #9575cd); }
.card-invoices .card-strip { background: linear-gradient(180deg, #0d9488, #2dd4bf); }
.card-tokens .card-strip { background: linear-gradient(180deg, #b45309, #f59e0b); }
.card-envios .card-strip { background: linear-gradient(180deg, #0369a1, #38bdf8); }
.card-audit .card-strip { background: linear-gradient(180deg, #4338ca, #818cf8); }

.card-body {
    padding: 1.1rem 1.3rem;
    flex: 1;
}

.card-body h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.card-body p {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-bottom: 0.6rem;
    line-height: 1.4;
}

.card-link {
    font-size: 0.78rem;
    font-weight: 600;
    color: #4fc3f7;
    transition: color 0.2s;
}

.dash-card:hover .card-link {
    color: #0288d1;
}

@media (max-width: 768px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .card-grid { grid-template-columns: 1fr; }
}

/* ========== TABS ========== */
.tab-nav {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.7rem 1.5rem;
    border: none;
    background: none;
    color: #888;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover {
    color: #555;
}

.tab-btn.active {
    color: #4fc3f7;
    border-bottom-color: #4fc3f7;
}

.client-list-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.4rem;
    max-height: 200px;
    overflow-y: auto;
    padding: 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fafafa;
}

.client-list-checkboxes label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: normal;
    cursor: pointer;
}

/* ========== BLAZOR SPECIFIC ========== */
#blazor-error-ui {
    display: none;
    background: #dc2626;
    color: #fff;
    padding: 0.5rem;
    text-align: center;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 999;
}
