@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap');

/* ==========================================================
   GIORGETA CRM - VARIABLES
========================================================== */

:root {
    --color-primary: #0E8743;
    --color-primary-dark: #0a6331;
    --color-secondary: #FBA81C;
    --color-white: #FFFFFF;

    --color-bg: #f6f8f7;
    --color-card: #FFFFFF;
    --color-text: #1f2933;
    --color-muted: #6b7280;
    --color-border: #e5e7eb;

    --color-danger: #dc2626;
    --color-danger-bg: #fef2f2;
    --color-success-bg: #ecfdf3;
    --color-soft-green: #f0fdf4;
    --color-soft-orange: #fff7ed;

    --font-main: "Nunito", Arial, Helvetica, sans-serif;

    --radius-sm: 12px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --radius-pill: 999px;

    --shadow-card: 0 14px 30px rgba(15, 23, 42, 0.08);
}

/* ==========================================================
   RESET Y BASE
========================================================== */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-main);
    background: var(--color-bg);
    color: var(--color-text);
}

a {
    color: inherit;
}

.mt-20 {
    margin-top: 20px;
}

/* ==========================================================
   LOGIN
========================================================== */

.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(14, 135, 67, 0.14), transparent 30%),
        radial-gradient(circle at bottom right, rgba(251, 168, 28, 0.18), transparent 32%),
        var(--color-bg);
}

.auth-card {
    width: 100%;
    max-width: 430px;
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 34px;
    box-shadow: var(--shadow-card);
}

.logo-auth {
    display: block;
    width: 200px;
    height: 200px;
    margin: 0 auto 20px;
    object-fit: contain;
}

.auth-card h1 {
    margin: 0;
    text-align: center;
    color: var(--color-primary);
    font-size: 2rem;
    font-weight: 800;
}

.auth-text {
    text-align: center;
    margin: 10px 0 26px;
    color: var(--color-muted);
}

/* ==========================================================
   LAYOUT GENERAL
========================================================== */

.app-body {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 270px;
    min-height: 100vh;
    background: var(--color-primary);
    color: var(--color-white);
    padding: 22px;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
}

.main-content {
    margin-left: 270px;
    width: calc(100% - 270px);
    padding: 30px;
}

/* ==========================================================
   SIDEBAR
========================================================== */

.sidebar-brand {
    padding-bottom: 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.sidebar-brand a {
    display: flex;
    gap: 14px;
    align-items: center;
    color: inherit;
    text-decoration: none;
}

.logo-sidebar {
    width: 70px;
    height: 70px;
    display: block;
    object-fit: contain;
    background-color: var(--color-white);
    border-radius: 15px;
}

.sidebar-brand strong {
    display: block;
    font-size: 1.15rem;
    font-weight: 800;
}

.sidebar-brand span {
    display: block;
    font-size: 0.85rem;
    opacity: 0.85;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 26px;
}

.sidebar-nav a {
    text-decoration: none;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    opacity: 0.92;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.16);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.sidebar-footer span {
    display: block;
    font-weight: 800;
    margin-bottom: 8px;
}

.sidebar-footer a {
    color: var(--color-secondary);
    font-weight: 800;
    text-decoration: none;
}

/* ==========================================================
   CABECERA SUPERIOR
========================================================== */

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    margin-bottom: 24px;
}

.topbar h1 {
    margin: 0;
    font-size: 2rem;
    color: var(--color-primary);
}

.topbar p {
    margin: 6px 0 0;
    color: var(--color-muted);
}

.user-pill {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    padding: 10px 16px;
    font-weight: 800;
    color: var(--color-primary);
}

/* ==========================================================
   BOTONES
========================================================== */

.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 13px 18px;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-white);
    margin-top: 12px;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-light {
    background: var(--color-white);
    color: var(--color-primary);
    border: 1px solid var(--color-border);
}

.btn-light:hover {
    background: var(--color-bg);
}

.btn-table {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary);
    color: var(--color-white);
    border-radius: var(--radius-pill);
    padding: 7px 12px;
    font-weight: 800;
    text-decoration: none;
    font-size: 0.88rem;
    white-space: nowrap;
}

.btn-table:hover {
    background: var(--color-primary-dark);
}

/* ==========================================================
   ALERTAS
========================================================== */

.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-weight: 700;
}

.alert-error {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-primary);
}

/* ==========================================================
   FORMULARIOS Y FILTROS
========================================================== */

.form,
.filter-field {
    display: flex;
    flex-direction: column;
}

.form {
    gap: 10px;
}

.form label,
.filter-field label {
    font-weight: 800;
    color: var(--color-text);
}

.form input,
.form select,
.form textarea,
.filter-field input,
.filter-field select,
.filter-field textarea {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 12px 13px;
    font-family: var(--font-main);
    font-size: 0.98rem;
    background: var(--color-white);
    outline: none;
}

.form input,
.form select,
.form textarea {
    padding: 13px 14px;
    font-size: 1rem;
}

.form textarea,
.filter-field textarea {
    resize: vertical;
    min-height: 96px;
}

.form input:focus,
.form select:focus,
.form textarea:focus,
.filter-field input:focus,
.filter-field select:focus,
.filter-field textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(14, 135, 67, 0.12);
}

.filters-form {
    margin-top: 18px;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.filter-field {
    gap: 7px;
}

.filters-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

/* ==========================================================
   TARJETAS
========================================================== */

.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.card,
.content-card {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-card);
}

.card-label {
    display: block;
    color: var(--color-muted);
    font-weight: 700;
    margin-bottom: 8px;
}

.card strong {
    display: block;
    color: var(--color-primary);
    font-size: 2.2rem;
    font-weight: 800;
}

.card small {
    display: block;
    color: var(--color-muted);
    margin-top: 8px;
}

.card-text-small {
    font-size: 1.3rem !important;
}

.content-card {
    margin-bottom: 22px;
}

.content-card h2 {
    margin: 0 0 10px;
    color: var(--color-primary);
}

.content-card p {
    margin: 0;
    color: var(--color-muted);
    line-height: 1.6;
}

/* ==========================================================
   TARJETAS DE DINERO / IVA
========================================================== */

.card-money {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.money-block {
    border-radius: 16px;
    padding: 14px;
    background: var(--color-soft-green);
    border: 1px solid rgba(14, 135, 67, 0.16);
}

.money-block span {
    display: block;
    color: var(--color-muted);
    font-size: 0.88rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.money-block strong {
    display: block;
    color: var(--color-primary);
    font-size: 1.55rem;
    font-weight: 800;
}

.money-block.secondary {
    background: var(--color-soft-orange);
    border-color: rgba(251, 168, 28, 0.25);
}

.money-block.secondary strong {
    color: #b45309;
}

/* ==========================================================
   CABECERAS DE SECCIÓN
========================================================== */

.section-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.section-header h2 {
    margin-bottom: 6px;
}

.section-header p {
    margin: 0;
    color: var(--color-muted);
}

/* ==========================================================
   TABLAS
========================================================== */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    margin-top: 18px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

.compact-table {
    min-width: 520px;
}

.data-table th,
.data-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    background: var(--color-bg);
    color: var(--color-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table td {
    color: var(--color-text);
}

.data-table tr:hover td {
    background: #fbfdfc;
}

.data-table small {
    color: var(--color-muted);
}

/* ==========================================================
   ESTADOS E INFO
========================================================== */

.info-grid,
.info-list {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 0;
    border-bottom: 1px solid var(--color-border);
}

.info-row strong {
    color: var(--color-text);
}

.info-row span {
    color: var(--color-muted);
    text-align: right;
}

/* ==========================================================
   BADGES / ESTADOS VISUALES DE PEDIDO
========================================================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-pill);
    padding: 6px 11px;
    background: #f3f4f6;
    color: #374151;
    font-size: 0.88rem;
    font-weight: 800;
    white-space: nowrap;
}

.status-badge-large {
    padding: 9px 14px;
    font-size: 0.95rem;
}

.status-ok,
.status-badge.status-completed {
    background: var(--color-success-bg);
    color: var(--color-primary);
}

.status-error,
.status-badge.status-cancelled,
.status-badge.status-failed {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.status-badge.status-pending {
    background: #f3f4f6;
    color: #374151;
}

.status-badge.status-processing {
    background: #e0f2fe;
    color: #0369a1;
}

.status-badge.status-on-hold {
    background: #fff7ed;
    color: #c2410c;
}

.status-badge.status-refunded {
    background: #f5f3ff;
    color: #7c3aed;
}

.status-badge.status-unknown {
    background: #f3f4f6;
    color: #6b7280;
}

.status-list {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.status-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-white);
}

.status-item span {
    font-weight: 700;
    color: var(--color-text);
}

.status-item strong {
    color: var(--color-primary);
    font-size: 1.25rem;
}

.data-table td .status-badge {
    margin-top: 0;
}

/* ==========================================================
   PAGINACIÓN
========================================================== */

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 22px;
}

.page-link,
.page-current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-pill);
    padding: 9px 14px;
    font-weight: 800;
    text-decoration: none;
}

.page-link {
    background: var(--color-primary);
    color: var(--color-white);
}

.page-link:hover {
    background: var(--color-primary-dark);
}

.page-current {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    color: var(--color-muted);
}

/* ==========================================================
   DETALLES
========================================================== */

.detail-actions {
    margin-bottom: 18px;
}

.content-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
    margin-bottom: 22px;
}

/* ==========================================================
   PRODUCTOS
========================================================== */

.product-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.product-thumb {
    width: 58px;
    height: 58px;
    border-radius: var(--radius-md);
    object-fit: cover;
    background: var(--color-bg);
    flex-shrink: 0;
}

.product-thumb-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--color-muted);
    text-align: center;
    padding: 5px;
}

/* ==========================================================
   CLIENTES
========================================================== */

.inline-link {
    color: var(--color-primary);
    font-weight: 800;
    text-decoration: none;
}

.inline-link:hover {
    text-decoration: underline;
}

/* ==========================================================
   SINCRONIZACIÓN
========================================================== */

.sync-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.sync-option {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 22px;
    background: var(--color-white);
}

.sync-option h3 {
    margin: 0 0 10px;
    color: var(--color-primary);
}

.sync-option p {
    margin: 0 0 18px;
    color: var(--color-muted);
    line-height: 1.6;
}

.progress-bar {
    width: 100%;
    height: 16px;
    background: var(--color-border);
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin: 16px 0 20px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius-pill);
}

/* ==========================================================
   ESTADÍSTICAS Y GRÁFICAS
========================================================== */

.chart-box {
    position: relative;
    width: 100%;
    height: 330px;
    margin-top: 18px;
}

/* ==========================================================
   EXPORTACIONES
========================================================== */

.export-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
    margin-bottom: 22px;
}

.export-card {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border);
}

.export-card h2 {
    margin: 0 0 10px;
    color: var(--color-primary);
}

.export-card p {
    color: var(--color-muted);
    line-height: 1.6;
    margin: 0 0 18px;
}

/* ==========================================================
   FIX FINAL - COLORES DE ESTADOS DE PEDIDO
   Colocado al final para que tenga prioridad real.
========================================================== */

.status-badge.status-pending {
    background-color: #f3f4f6 !important;
    color: #374151 !important;
}

.status-badge.status-processing {
    background-color: #dbeafe !important;
    color: #1d4ed8 !important;
}

.status-badge.status-on-hold {
    background-color: #ffedd5 !important;
    color: #c2410c !important;
}

.status-badge.status-completed {
    background-color: #dcfce7 !important;
    color: #15803d !important;
}

.status-badge.status-cancelled {
    background-color: #fee2e2 !important;
    color: #dc2626 !important;
}

.status-badge.status-refunded {
    background-color: #ede9fe !important;
    color: #7c3aed !important;
}

.status-badge.status-failed {
    background-color: #fecaca !important;
    color: #991b1b !important;
}

.status-badge.status-unknown {
    background-color: #f3f4f6 !important;
    color: #6b7280 !important;
}

.status-badge-large {
    padding: 9px 14px !important;
    font-size: 0.95rem !important;
}

/* ==========================================================
   RESPONSIVE
========================================================== */

@media (max-width: 1000px) {
    .cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filters-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .content-grid-2,
    .export-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .app-body {
        display: block;
    }

    .sidebar {
        position: static;
        width: 100%;
        min-height: auto;
    }

    .main-content {
        width: 100%;
        margin-left: 0;
        padding: 20px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .cards-grid,
    .filters-grid,
    .sync-actions-grid {
        grid-template-columns: 1fr;
    }
}