/* =====================================================
   Sistema de Seguimiento de Ventas - Estilos Globales
   ===================================================== */

* { box-sizing: border-box; }

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --success: #48bb78;
    --danger: #f56565;
    --warning: #ed8936;
    --info: #4299e1;
    --dark: #2d3748;
    --gray: #718096;
    --light-gray: #e2e8f0;
    --bg: #f7fafc;
    --white: #ffffff;
    --sidebar-width: 260px;
    --header-height: 64px;
    --border-radius: 10px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

body {
    margin: 0;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--dark);
    font-size: 14px;
    line-height: 1.5;
}

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

/* ============ LAYOUT ============ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    transition: transform 0.3s;
    z-index: 100;
}

.sidebar-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.sidebar-header i {
    font-size: 1.8rem;
    color: var(--primary);
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.sidebar-header small {
    color: rgba(255,255,255,0.5);
    font-size: 0.75rem;
}

.sidebar-user {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.sidebar-user .avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.sidebar-user .info h4 {
    margin: 0;
    font-size: 0.9rem;
}

.sidebar-user .info p {
    margin: 0;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.6);
    text-transform: capitalize;
}

.sidebar-menu {
    padding: 0.5rem 0;
    list-style: none;
    margin: 0;
}

.sidebar-menu li {
    margin: 2px 0;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.75);
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.sidebar-menu a.active {
    background: rgba(102, 126, 234, 0.15);
    color: white;
    border-left-color: var(--primary);
}

.sidebar-menu a i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-menu .section-title {
    padding: 0.8rem 1.5rem 0.3rem;
    color: rgba(255,255,255,0.4);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--header-height);
    background: white;
    box-shadow: var(--shadow-sm);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--dark);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-actions .btn-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--bg);
    border: none;
    cursor: pointer;
    position: relative;
    color: var(--gray);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.topbar-actions .btn-icon:hover {
    background: var(--light-gray);
    color: var(--primary);
}

.badge-notification {
    position: absolute;
    top: -4px; right: -4px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    font-size: 0.65rem;
    width: 18px; height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.content {
    padding: 1.5rem;
    flex: 1;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--dark);
}

/* ============ CARDS ============ */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--light-gray);
}

.card-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

/* ============ STATS CARDS ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.2rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: white;
    padding: 1.3rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s;
}

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

.stat-card .stat-icon {
    width: 50px; height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: white;
    margin-bottom: 0.8rem;
}

.stat-card.primary .stat-icon { background: linear-gradient(135deg, #667eea, #764ba2); }
.stat-card.success .stat-icon { background: linear-gradient(135deg, #48bb78, #38a169); }
.stat-card.warning .stat-icon { background: linear-gradient(135deg, #ed8936, #dd6b20); }
.stat-card.danger .stat-icon { background: linear-gradient(135deg, #f56565, #e53e3e); }
.stat-card.info .stat-icon { background: linear-gradient(135deg, #4299e1, #3182ce); }

.stat-card .stat-label {
    color: var(--gray);
    font-size: 0.85rem;
    margin: 0;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0.2rem 0;
}

.stat-card .stat-change {
    font-size: 0.8rem;
    color: var(--success);
}

.stat-card .stat-change.negative { color: var(--danger); }

/* ============ BUTTONS ============ */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

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

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #38a169; color: white; }

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

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #dd6b20; color: white; }

.btn-secondary { background: var(--light-gray); color: var(--dark); }
.btn-secondary:hover { background: #cbd5e0; color: var(--dark); }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

.btn-icon-sm {
    width: 32px; height: 32px;
    padding: 0;
    justify-content: center;
    border-radius: 8px;
}

/* ============ TABLES ============ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--border-radius);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

table.data-table th {
    background: #f7fafc;
    text-align: left;
    padding: 0.85rem 1rem;
    font-weight: 600;
    color: var(--gray);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--light-gray);
}

table.data-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--light-gray);
    font-size: 0.9rem;
}

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

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--dark);
    font-size: 0.88rem;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 2px solid var(--light-gray);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
    font-family: inherit;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
}

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ============ BADGES ============ */
.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #c6f6d5; color: #22543d; }
.badge-danger { background: #fed7d7; color: #742a2a; }
.badge-warning { background: #feebc8; color: #744210; }
.badge-info { background: #bee3f8; color: #2a4365; }
.badge-secondary { background: #e2e8f0; color: #2d3748; }

/* ============ ALERTS ============ */
.alert {
    padding: 0.9rem 1.2rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.alert-success { background: #c6f6d5; color: #22543d; border-left: 4px solid #38a169; }
.alert-danger { background: #fed7d7; color: #742a2a; border-left: 4px solid #e53e3e; }
.alert-warning { background: #feebc8; color: #744210; border-left: 4px solid #dd6b20; }
.alert-info { background: #bee3f8; color: #2a4365; border-left: 4px solid #3182ce; }

/* ============ MAP ============ */
#map, .map-container {
    height: 500px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* ============ MODAL ============ */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}
.modal-overlay.active { display: flex; }

.modal {
    background: white;
    border-radius: var(--border-radius);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { margin: 0; }

.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--light-gray);
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--gray);
}

/* ============ UTILITIES ============ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.w-100 { width: 100%; }

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

.page-header h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--dark);
}

.page-header .breadcrumb {
    color: var(--gray);
    font-size: 0.85rem;
    margin-top: 0.2rem;
}

/* ============ CHART ============ */
.chart-container { position: relative; height: 300px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
    .mobile-toggle {
        display: block;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ============ LOGIN ============ */
/* (Already styled inline in login) */

/* ============ LOADING ============ */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(102,126,234,0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

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

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state h3 {
    color: var(--dark);
    margin: 0.5rem 0;
}
