/* ═══════════════════════════════════════════════════════════════
   CAFÉ RAYUELA — components.css
   Botones, Cards, Tablas, Formularios y componentes reutilizables
   ═══════════════════════════════════════════════════════════════ */

/* ══ BUTTONS ══ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 9px var(--space-4);
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--tr-fast);
    white-space: nowrap;
    line-height: 1;
    text-decoration: none;
    outline: none;
}

.btn:focus-visible {
    outline: 2px solid var(--cr-amber);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn:active {
    transform: scale(.98);
}

/* Sizes */
.btn-xs {
    padding: 5px 10px;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.btn-sm {
    padding: 7px 12px;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 0.9375rem;
}

.btn-xl {
    padding: 14px 28px;
    font-size: 1rem;
    border-radius: var(--radius-lg);
}

.btn-full {
    width: 100%;
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius);
    width: 34px;
    height: 34px;
}

.btn-icon.btn-sm {
    width: 28px;
    height: 28px;
    padding: 5px;
}

/* Variants */
.btn-primary {
    background: linear-gradient(135deg, var(--cr-amber) 0%, var(--cr-amber-dark) 100%);
    color: #fff;
    border-color: var(--cr-amber);
    box-shadow: 0 2px 6px rgba(180, 83, 9, .3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--cr-amber-dark) 0%, #78350f 100%);
    box-shadow: 0 4px 10px rgba(180, 83, 9, .4);
}

.btn-secondary {
    background: var(--cr-white);
    color: var(--cr-dark);
    border-color: var(--cr-border);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    border-color: var(--cr-pale);
    background: var(--cr-surface);
}

.btn-success {
    background: linear-gradient(135deg, var(--cr-green) 0%, #047857 100%);
    color: #fff;
    border-color: var(--cr-green);
}

.btn-success:hover {
    filter: brightness(1.1);
}

.btn-danger {
    background: linear-gradient(135deg, var(--cr-red) 0%, #b91c1c 100%);
    color: #fff;
    border-color: var(--cr-red);
}

.btn-danger:hover {
    filter: brightness(1.1);
}

.btn-info {
    background: linear-gradient(135deg, var(--cr-blue) 0%, #1d4ed8 100%);
    color: #fff;
    border-color: var(--cr-blue);
}

.btn-info:hover {
    filter: brightness(1.1);
}

.btn-ghost {
    background: transparent;
    color: var(--cr-mid);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--cr-border);
    color: var(--cr-dark);
}

.btn-ghost-primary {
    background: transparent;
    color: var(--cr-amber);
    border-color: transparent;
}

.btn-ghost-primary:hover {
    background: var(--cr-amber-light);
}

.btn-outline {
    background: transparent;
    border-color: var(--cr-border);
    color: var(--cr-mid);
}

.btn-outline:hover {
    border-color: var(--cr-amber);
    color: var(--cr-amber);
    background: var(--cr-amber-pale);
}

/* Button group */
.btn-group {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.btn-group-attached {
    display: flex;
}

.btn-group-attached .btn {
    border-radius: 0;
    border-right-width: 0;
}

.btn-group-attached .btn:first-child {
    border-radius: var(--radius) 0 0 var(--radius);
}

.btn-group-attached .btn:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
    border-right-width: 1px;
}

/* ══ CARDS ══ */
.card {
    background: var(--cr-white);
    border: 1px solid var(--cr-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--cr-border);
    background: var(--cr-surface);
}

.card-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--cr-dark);
    margin: 0;
}

.card-body {
    padding: var(--space-5);
}

.card-footer {
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--cr-border);
    background: var(--cr-surface);
}

/* KPI Card */
.kpi-card {
    background: var(--cr-white);
    border: 1px solid var(--cr-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--tr-fast), border-color var(--tr-fast);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.kpi-card.kpi-amber::before {
    background: var(--cr-amber);
}

.kpi-card.kpi-green::before {
    background: var(--cr-green);
}

.kpi-card.kpi-blue::before {
    background: var(--cr-blue);
}

.kpi-card.kpi-red::before {
    background: var(--cr-red);
}

.kpi-card.kpi-purple::before {
    background: var(--cr-purple);
}

.kpi-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--cr-pale);
}

.kpi-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-2);
}

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.kpi-icon.amber {
    background: var(--cr-amber-light);
}

.kpi-icon.green {
    background: var(--cr-green-light);
}

.kpi-icon.blue {
    background: var(--cr-blue-light);
}

.kpi-icon.red {
    background: var(--cr-red-light);
}

.kpi-icon.purple {
    background: var(--cr-purple-light);
}

/* ══ TABLES ══ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--cr-border);
    box-shadow: var(--shadow-sm);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: var(--cr-white);
}

.table thead tr {
    background: var(--cr-surface);
    border-bottom: 2px solid var(--cr-border);
}

.table thead th {
    padding: 11px var(--space-4);
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--cr-mid);
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}

.table tbody tr {
    border-bottom: 1px solid var(--cr-border);
    transition: background var(--tr-fast);
}

.table tbody tr:last-child {
    border-bottom: none;
}

.table tbody tr:hover {
    background: var(--cr-surface);
}

.table tbody td {
    padding: 12px var(--space-4);
    vertical-align: middle;
    color: var(--cr-dark);
}

.table-sm thead th,
.table-sm tbody td {
    padding: 8px var(--space-3);
}

.table-striped tbody tr:nth-child(even) {
    background: var(--cr-surface);
}

.table-striped tbody tr:nth-child(even):hover {
    background: #f1f5f9;
}

/* ══ FORMS ══ */
.form-group {
    margin-bottom: var(--space-4);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-4);
}

label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--cr-dark-3);
    margin-bottom: var(--space-2);
}

label .required {
    color: var(--cr-red);
    margin-left: 2px;
}

.form-control,
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="search"],
select,
textarea {
    display: block;
    width: 100%;
    padding: 9px var(--space-3);
    border: 1px solid var(--cr-border);
    border-radius: var(--radius);
    background: var(--cr-white);
    color: var(--cr-dark);
    font-size: 0.875rem;
    line-height: 1.5;
    transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
    outline: none;
    -webkit-appearance: none;
}

.form-control:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
    border-color: var(--cr-amber);
    box-shadow: 0 0 0 3px rgba(180, 83, 9, .12);
}

.form-control::placeholder {
    color: var(--cr-pale);
}

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

select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    display: none;
}

.form-control.is-error {
    border-color: var(--cr-red);
}

.form-control.is-error:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}

.form-error {
    font-size: 0.75rem;
    color: var(--cr-red);
    margin-top: var(--space-1);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--cr-light);
    margin-top: var(--space-1);
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--cr-border);
    border-radius: 3px;
    background: var(--cr-white);
    cursor: pointer;
    accent-color: var(--cr-amber);
}

.form-check label {
    margin-bottom: 0;
    font-weight: 400;
    cursor: pointer;
}

/* Input with prefix/suffix */
.input-group {
    display: flex;
    align-items: stretch;
}

.input-prefix,
.input-suffix {
    display: flex;
    align-items: center;
    padding: 9px var(--space-3);
    background: var(--cr-surface);
    border: 1px solid var(--cr-border);
    font-size: 0.875rem;
    color: var(--cr-mid);
    font-weight: 600;
}

.input-prefix {
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
}

.input-suffix {
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.input-group .form-control {
    border-radius: 0;
}

.input-group .form-control:first-child:last-child {
    border-radius: var(--radius);
}

.input-group .input-prefix+.form-control {
    border-radius: 0 var(--radius) var(--radius) 0;
}

.input-group .form-control+.input-suffix {
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* Search input */
.search-box {
    position: relative;
}

.search-box .search-icon {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--cr-light);
    font-size: 0.9rem;
    pointer-events: none;
}

.search-box input {
    padding-left: 34px;
}

/* ══ TABS ══ */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--cr-border);
    margin-bottom: var(--space-5);
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--cr-mid);
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--tr-fast), border-color var(--tr-fast);
}

.tab-btn:hover {
    color: var(--cr-dark);
}

.tab-btn.active {
    color: var(--cr-amber);
    border-bottom-color: var(--cr-amber);
    font-weight: 600;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ══ CALLOUTS ══ */
.callout {
    border-radius: var(--radius);
    padding: var(--space-4);
    border-left: 4px solid;
    font-size: 0.875rem;
    margin-bottom: var(--space-4);
    display: flex;
    gap: var(--space-3);
}

.callout-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.callout-body strong {
    display: block;
    font-weight: 700;
    margin-bottom: 2px;
}

.callout-info {
    background: var(--cr-blue-light);
    border-color: var(--cr-blue);
    color: var(--cr-blue);
}

.callout-success {
    background: var(--cr-green-light);
    border-color: var(--cr-green);
    color: var(--cr-green);
}

.callout-warning {
    background: var(--cr-amber-light);
    border-color: var(--cr-amber);
    color: var(--cr-amber-dark);
}

.callout-danger {
    background: var(--cr-red-light);
    border-color: var(--cr-red);
    color: var(--cr-red);
}

/* ══ PAGINATION ══ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--cr-border);
    font-size: 0.8rem;
    color: var(--cr-mid);
}

.pagination-controls {
    display: flex;
    gap: var(--space-2);
}

.page-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--cr-border);
    border-radius: var(--radius);
    background: var(--cr-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--cr-mid);
    transition: all var(--tr-fast);
}

.page-btn:hover {
    border-color: var(--cr-amber);
    color: var(--cr-amber);
}

.page-btn.active {
    background: var(--cr-amber);
    color: #fff;
    border-color: var(--cr-amber);
}

.page-btn:disabled {
    opacity: .4;
    cursor: default;
}

/* ══ FILTER / TOOLBAR ══ */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    flex: 1;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* ══ SECTION TITLE ══ */
.section-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--cr-mid);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--cr-border);
}

/* ══ PILL / TAG ══ */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--cr-border);
    color: var(--cr-mid);
}

.pill-amber {
    background: var(--cr-amber-light);
    color: var(--cr-amber-dark);
}

.pill-green {
    background: var(--cr-green-light);
    color: var(--cr-green);
}

.pill-red {
    background: var(--cr-red-light);
    color: var(--cr-red);
}

.pill-blue {
    background: var(--cr-blue-light);
    color: var(--cr-blue);
}

.pill-purple {
    background: var(--cr-purple-light);
    color: var(--cr-purple);
}

/* ══ PROGRESS BAR ══ */
.progress {
    height: 6px;
    background: var(--cr-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--cr-amber) 0%, var(--cr-amber-dark) 100%);
    transition: width .4s ease;
}

.progress-bar.green {
    background: linear-gradient(90deg, var(--cr-green) 0%, #047857 100%);
}

.progress-bar.red {
    background: linear-gradient(90deg, var(--cr-red) 0%, #b91c1c 100%);
}

.progress-bar.blue {
    background: linear-gradient(90deg, var(--cr-blue) 0%, #1d4ed8 100%);
}

.progress-bar.purple {
    background: linear-gradient(90deg, var(--cr-purple) 0%, #6d28d9 100%);
}

/* ══ MODAL CONFIRM ══ */
.confirm-modal {
    padding: var(--space-6);
    text-align: center;
}

.confirm-modal .confirm-icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
}

.confirm-modal h3 {
    margin-bottom: var(--space-2);
}

.confirm-modal p {
    color: var(--cr-mid);
    font-size: 0.875rem;
    margin-bottom: var(--space-5);
}

.confirm-modal .btn-group {
    justify-content: center;
}

/* ══ CHART WRAPPER ══ */
.chart-wrapper {
    position: relative;
}

.chart-wrapper canvas {
    max-width: 100%;
}