/**
 * Estilos del Frontend - Coffee Crew
 * Usa tokens de coffeecrew-tokens.css. Solo afecta a .coffeecrew-* para no impactar el theme.
 *
 * @package CoffeeCrew
 */

/* ===== Aislamiento: contenedores del plugin ===== */
.coffeecrew-frontend-dashboard,
.coffeecrew-frontend-scan,
.coffeecrew-frontend-history,
.coffeecrew-cafeteria-wrapper {
    --cc-ctx-bg: var(--cc-bg);
    --cc-ctx-text: var(--cc-text);
    --cc-ctx-heading: var(--cc-heading);
}

/* ===== Container (shortcodes antiguos) ===== */
.coffeecrew-frontend-dashboard,
.coffeecrew-frontend-scan,
.coffeecrew-frontend-history {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: var(--cc-bg);
}

/* ===== User Info ===== */
.coffeecrew-user-info {
    background: var(--cc-surface);
    padding: 15px 20px;
    border-radius: var(--cc-border-radius-lg);
    box-shadow: var(--cc-box-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border: 1px solid var(--cc-border-light);
}

.coffeecrew-user-info p {
    margin: 0;
    font-size: 16px;
    color: var(--cc-text);
}

.coffeecrew-logout-button {
    background: var(--cc-secondary) !important;
    border-color: var(--cc-secondary) !important;
    color: var(--cc-secondary-text-on) !important;
}
.coffeecrew-logout-button:hover {
    background: var(--cc-secondary-hover) !important;
    border-color: var(--cc-secondary-hover) !important;
}

/* ===== Login Form ===== */
.coffeecrew-login-form {
    max-width: 400px;
    margin: 40px auto;
    padding: 30px;
    background: var(--cc-surface);
    border-radius: var(--cc-border-radius-lg);
    box-shadow: var(--cc-box-shadow);
    border: 1px solid var(--cc-border-light);
}

.coffeecrew-login-form h2 {
    text-align: center;
    color: var(--cc-heading);
    margin-top: 0;
}

.coffeecrew-login-help {
    text-align: center;
    margin-top: 15px;
}

/* ===== Página login-cafeteria (body con clase coffeecrew-login-body) ===== */
body.coffeecrew-login-body {
    background: var(--cc-base);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coffeecrew-login-page {
    width: 100%;
    max-width: 440px;
    margin: 0;
    padding: 24px;
    box-sizing: border-box;
}

.coffeecrew-login-box {
    background: var(--cc-bg);
    border-radius: var(--cc-border-radius-lg);
    padding: 32px 28px;
    box-shadow: var(--cc-box-shadow-hover);
    border: 1px solid var(--cc-border-light);
}

.coffeecrew-login-logo {
    display: block;
    max-width: 200px;
    width: 100%;
    height: auto;
    margin: 0 auto 24px;
}

.coffeecrew-login-header {
    text-align: center;
    margin-bottom: 24px;
}

.coffeecrew-login-header h1 {
    color: var(--cc-heading);
    margin: 0 0 8px 0;
    font-size: 1.5rem;
}

.coffeecrew-login-header .coffeecrew-text-muted {
    margin: 0;
    font-size: 0.95rem;
}

.coffeecrew-login-box .coffeecrew-alert-danger {
    margin-bottom: 20px;
}

.coffeecrew-login-box form p {
    margin-bottom: 16px;
}

.coffeecrew-login-box form p:last-of-type {
    margin-bottom: 0;
}

.coffeecrew-login-box label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--cc-heading);
}

.coffeecrew-login-box .coffeecrew-f-input {
    width: 100%;
    box-sizing: border-box;
}

.coffeecrew-login-submit {
    width: 100%;
    background: var(--cc-base) !important;
    border: none !important;
    border-radius: var(--cc-border-radius) !important;
    color: var(--cc-base-text-on) !important;
    padding: 12px 20px !important;
    cursor: pointer;
}

.coffeecrew-login-submit:hover {
    background: var(--cc-base-hover) !important;
    color: var(--cc-base-text-on) !important;
}

/* ===== Welcome ===== */
.coffeecrew-welcome {
    text-align: center;
    margin-bottom: 30px;
}

.coffeecrew-welcome h2 {
    color: var(--cc-heading);
    margin-bottom: 10px;
}

/* ===== Stats Grid ===== */
.coffeecrew-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.coffeecrew-stat-card {
    background: var(--cc-surface);
    padding: 25px;
    border-radius: var(--cc-border-radius-lg);
    box-shadow: var(--cc-box-shadow);
    text-align: center;
    transition: transform 0.3s ease;
    border: 1px solid var(--cc-border-light);
}

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

.coffeecrew-stat-card .stat-icon {
    font-size: 48px;
    margin-bottom: 10px;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.coffeecrew-stat-card h3 {
    font-size: 36px;
    color: var(--cc-heading);
    margin: 10px 0;
}

.coffeecrew-stat-card p {
    color: var(--cc-text);
    margin: 0;
    opacity: 0.9;
}

.coffeecrew-stat-card .stat-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.coffeecrew-stat-card .stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--cc-heading);
    line-height: 1;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
}

.coffeecrew-stat-card .stat-label {
    font-size: 14px;
    color: var(--cc-text);
    font-weight: 500;
    text-align: center;
    opacity: 0.9;
}

.stat-value-small {
    font-size: 14px !important;
    color: var(--cc-secondary) !important;
    font-weight: 600;
}

/* ===== Quick Actions ===== */
.coffeecrew-quick-actions {
    background: var(--cc-surface);
    padding: 25px;
    border-radius: var(--cc-border-radius-lg);
    box-shadow: var(--cc-box-shadow);
    margin: 20px 0;
    border: 1px solid var(--cc-border-light);
}

.coffeecrew-quick-actions h3 {
    color: var(--cc-heading);
    margin-top: 0;
}

.coffeecrew-action-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.coffeecrew-action-button {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: linear-gradient(135deg, var(--cc-base), var(--cc-base-hover));
    color: var(--cc-base-text-on) !important;
    text-decoration: none !important;
    border-radius: var(--cc-border-radius-lg);
    transition: transform 0.3s ease, background 0.3s ease;
}
.coffeecrew-action-button:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, var(--cc-base-hover), var(--cc-base)) !important;
}
.coffeecrew-action-button:focus {
    box-shadow: var(--cc-focus-ring);
}

.coffeecrew-action-button .action-icon {
    font-size: 32px;
}

.coffeecrew-action-button .action-text {
    font-size: 18px;
    font-weight: 600;
}

/* ===== Scan Section ===== */
.coffeecrew-scan-section,
.coffeecrew-scan-header {
    background: var(--cc-surface);
    padding: 25px;
    border-radius: var(--cc-border-radius-lg);
    box-shadow: var(--cc-box-shadow);
    margin: 20px 0;
    border: 1px solid var(--cc-border-light);
}

.coffeecrew-scan-header h2 {
    color: var(--cc-heading);
    margin-top: 0;
}

.coffeecrew-scan-container {
    padding: 20px 0;
}

.coffeecrew-scan-input {
    display: flex;
    gap: 10px;
    align-items: end;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.coffeecrew-scan-input label {
    flex: 0 0 100%;
    font-weight: 600;
    color: var(--cc-heading);
    margin-bottom: 5px;
}

.coffeecrew-nfc-input {
    flex: 1;
    min-width: 250px;
    padding: 12px 15px;
    border: 2px solid var(--cc-border);
    border-radius: var(--cc-border-radius-lg);
    font-size: 16px;
    transition: border-color 0.3s ease;
    background: var(--cc-surface);
    color: var(--cc-text);
}
.coffeecrew-nfc-input:focus {
    outline: none;
    border-color: var(--cc-accent);
    box-shadow: var(--cc-focus-ring);
}

/* ===== Element Info ===== */
.coffeecrew-element-info {
    background: var(--cc-surface-alt);
    padding: 25px;
    border-radius: var(--cc-border-radius-lg);
    margin: 20px 0;
    border: 2px solid var(--cc-border);
}

.coffeecrew-element-info h3 {
    color: var(--cc-heading);
    margin-top: 0;
}

.coffeecrew-element-info .element-details {
    background: var(--cc-surface);
    padding: 15px;
    border-radius: var(--cc-border-radius);
    margin: 15px 0;
    border: 1px solid var(--cc-border-light);
}

.coffeecrew-element-info .element-details p {
    margin: 8px 0;
    color: var(--cc-text);
}

.coffeecrew-element-info .element-progress {
    margin: 20px 0;
}

.coffeecrew-element-info .element-progress h4 {
    color: var(--cc-heading);
}

.coffeecrew-progress-bar-big {
    position: relative;
    width: 100%;
    height: 40px;
    background: var(--cc-surface-alt);
    border-radius: 20px;
    overflow: hidden;
    margin: 15px 0;
    border: 1px solid var(--cc-border-light);
}

.coffeecrew-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--cc-accent), var(--cc-accent-hover));
    transition: width 0.5s ease;
}

.coffeecrew-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    font-weight: 700;
    color: var(--cc-accent-text-on);
    text-shadow: var(--cc-text-shadow-soft);
}

.coffeecrew-element-info .progress-info {
    text-align: center;
    color: var(--cc-text);
    font-size: 14px;
    opacity: 0.9;
}

.element-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.element-actions button {
    flex: 1;
    min-width: 150px;
}
.element-actions .button-primary {
    background: var(--cc-accent) !important;
    border-color: var(--cc-accent) !important;
    color: var(--cc-accent-text-on) !important;
}
.element-actions .button-primary:hover {
    background: var(--cc-accent-hover) !important;
    border-color: var(--cc-accent-hover) !important;
}
.element-actions .button-primary:focus {
    box-shadow: var(--cc-focus-ring);
}

/* ===== Messages ===== */
.coffeecrew-message {
    padding: 15px 20px;
    border-radius: var(--cc-border-radius-lg);
    margin: 15px 0;
}

.coffeecrew-message-error {
    background: var(--cc-danger-bg);
    color: var(--cc-danger-text);
    border: 1px solid var(--cc-danger-border);
}

.coffeecrew-message-success {
    background: var(--cc-success-bg);
    color: var(--cc-success-text);
    border: 1px solid var(--cc-success-border);
}

/* ===== Purchase Result ===== */
.coffeecrew-result-box {
    padding: 30px;
    border-radius: var(--cc-border-radius-lg);
    text-align: center;
    margin: 20px 0;
}

.coffeecrew-result-success {
    background: var(--cc-success-bg);
    border: 2px solid var(--cc-success-border);
}

.coffeecrew-result-reward {
    background: var(--cc-warning-bg);
    border: 2px solid var(--cc-warning-border);
}

.coffeecrew-result-box h3 {
    font-size: 28px;
    margin-top: 0;
    color: var(--cc-heading);
}

.reward-info {
    margin: 20px 0;
}

.reward-icon {
    font-size: 80px;
    margin: 10px 0;
}

.reward-name {
    font-size: 24px;
    font-weight: 600;
    color: var(--cc-heading);
}

.reward-code {
    font-size: 18px;
    margin: 15px 0;
}

.reward-code code {
    background: var(--cc-surface);
    padding: 10px 20px;
    border-radius: var(--cc-border-radius);
    font-size: 20px;
    font-weight: 700;
    color: var(--cc-heading);
    letter-spacing: 2px;
    border: 1px solid var(--cc-border-light);
}

.reward-description {
    color: var(--cc-text);
    font-size: 16px;
    opacity: 0.9;
}

/* ===== History ===== */
.coffeecrew-history-table {
    background: var(--cc-surface);
    padding: 20px;
    border-radius: var(--cc-border-radius-lg);
    box-shadow: var(--cc-box-shadow);
    overflow-x: auto;
    border: 1px solid var(--cc-border-light);
}

.coffeecrew-table {
    width: 100%;
    border-collapse: collapse;
}

.coffeecrew-table thead {
    background: var(--cc-base);
    color: var(--cc-base-text-on);
}

.coffeecrew-table th,
.coffeecrew-table td {
    padding: 12px 15px;
    text-align: left;
    color: var(--cc-text);
}

.coffeecrew-table tbody tr {
    border-bottom: 1px solid var(--cc-border-light);
}

.coffeecrew-table tbody tr:hover {
    background: var(--cc-surface-alt);
}

.reward-badge {
    display: inline-block;
    padding: 5px 12px;
    background: var(--cc-accent);
    color: var(--cc-accent-text-on);
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
}

/* ===== Badges ===== */
.coffeecrew-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.coffeecrew-badge-active {
    background: var(--cc-success-bg);
    color: var(--cc-success-text);
    border: 1px solid var(--cc-success-border);
}

.coffeecrew-badge-purchase {
    background: var(--cc-info-bg);
    color: var(--cc-info-text);
    border: 1px solid var(--cc-info-border);
}

.coffeecrew-badge-reward_normal {
    background: var(--cc-success-bg);
    color: var(--cc-success-text);
    border: 1px solid var(--cc-success-border);
}

.coffeecrew-badge-reward_premium {
    background: var(--cc-warning-bg);
    color: var(--cc-warning-text);
    border: 1px solid var(--cc-warning-border);
}

.coffeecrew-badge-reward_random {
    background: var(--cc-accent-muted);
    color: var(--cc-base);
    border: 1px solid var(--cc-accent);
}

.coffeecrew-badge-reward_redeemed,
.coffeecrew-badge-element_created,
.coffeecrew-badge-element_activated,
.coffeecrew-badge-element_deactivated,
.coffeecrew-badge-manual_adjustment,
.coffeecrew-badge-test,
.coffeecrew-badge-test_debug {
    background: var(--cc-surface-alt);
    color: var(--cc-text);
    border: 1px solid var(--cc-border);
}

.coffeecrew-badge-pending {
    background: var(--cc-info-bg);
    color: var(--cc-info-text);
    border: 1px solid var(--cc-info-border);
}

/* ===== Empty State ===== */
.coffeecrew-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--cc-text);
    opacity: 0.9;
}

.coffeecrew-empty-state p {
    font-size: 18px;
    margin: 10px 0;
}

/* ===== Pagination ===== */
.coffeecrew-pagination {
    text-align: center;
    margin: 30px 0;
}

.coffeecrew-pagination .page-numbers,
.coffeecrew-pagination .page-link {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 5px;
    background: var(--cc-surface);
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-border-radius);
    text-decoration: none;
    color: var(--cc-heading);
    transition: all 0.2s;
}
.coffeecrew-pagination .page-numbers.current,
.coffeecrew-pagination .page-link.active {
    background: var(--cc-accent);
    color: var(--cc-accent-text-on);
    border-color: var(--cc-accent);
}
.coffeecrew-pagination .page-numbers:hover,
.coffeecrew-pagination .page-link:hover {
    background: var(--cc-accent-hover);
    color: var(--cc-accent-text-on);
    border-color: var(--cc-accent-hover);
}

/* ===== Access Denied ===== */
.coffeecrew-access-denied {
    background: var(--cc-warning-bg);
    border: 2px solid var(--cc-warning-border);
    padding: 30px;
    border-radius: var(--cc-border-radius-lg);
    text-align: center;
    margin: 40px auto;
    max-width: 600px;
}

.coffeecrew-access-denied h3 {
    color: var(--cc-warning-text);
    margin-top: 0;
}

/* ===== Scan Help ===== */
.coffeecrew-scan-help {
    background: var(--cc-info-bg);
    padding: 20px;
    border-radius: var(--cc-border-radius-lg);
    margin: 20px 0;
    border: 1px solid var(--cc-info-border);
}

.coffeecrew-scan-help h3 {
    color: var(--cc-heading);
    margin-top: 0;
}

.coffeecrew-scan-help ol {
    margin: 10px 0;
    padding-left: 20px;
}

.coffeecrew-scan-help li {
    margin: 8px 0;
    line-height: 1.6;
    color: var(--cc-text);
}

/* ===== Auto Scan Notice ===== */
.coffeecrew-auto-scan-notice {
    background: var(--cc-success-bg);
    border: 2px solid var(--cc-success-border);
    padding: 20px;
    border-radius: var(--cc-border-radius-lg);
    margin: 20px 0;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.coffeecrew-auto-scan-notice .info-message {
    font-size: 18px;
    font-weight: 600;
    color: var(--cc-success-text);
    margin: 0;
}

/* ===== Shortcode Cafetería (Dashboard + Historial Unificado) ===== */
.coffeecrew-cafeteria-wrapper {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    padding: 0 !important;
    box-sizing: border-box;
    overflow-x: hidden;
    background: var(--cc-bg);
}

body:has(.coffeecrew-cafeteria-wrapper) {
    overflow-x: hidden;
}

.coffeecrew-welcome-section {
    background: var(--cc-base);
    color: var(--cc-base-text-on);
    padding: 40px 20px;
    text-align: center;
    margin-bottom: 0;
}

.coffeecrew-welcome-section .welcome-title {
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 10px 0;
    color: var(--cc-base-text-on);
}

.coffeecrew-welcome-section .welcome-subtitle {
    font-size: 18px;
    margin: 0;
    opacity: 0.95;
    font-weight: 400;
}

.coffeecrew-renewal-notice {
    background: var(--cc-warning-bg);
    border: 3px solid var(--cc-warning-border);
    border-radius: var(--cc-border-radius-lg);
    padding: 30px;
    margin: 30px auto;
    max-width: 800px;
    display: flex;
    align-items: center;
    gap: 25px;
    box-shadow: var(--cc-box-shadow);
}

.coffeecrew-renewal-notice .renewal-icon {
    font-size: 64px;
    line-height: 1;
    flex-shrink: 0;
}

.coffeecrew-renewal-notice .renewal-content {
    flex: 1;
}

.coffeecrew-renewal-notice .renewal-title {
    color: var(--cc-warning-text);
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 10px 0;
}

.coffeecrew-renewal-notice .renewal-message {
    color: var(--cc-warning-text);
    font-size: 16px;
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.coffeecrew-renewal-notice .renewal-button {
    display: inline-block;
    background: var(--cc-secondary);
    color: var(--cc-secondary-text-on) !important;
    padding: 12px 30px;
    border-radius: var(--cc-border-radius);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
}
.coffeecrew-renewal-notice .renewal-button:hover {
    background: var(--cc-secondary-hover);
    transform: translateY(-2px);
}

.coffeecrew-renewal-notice .renewal-contact {
    color: var(--cc-warning-text);
    font-size: 14px;
    margin: 0;
    font-style: italic;
}

.coffeecrew-stats-section {
    background: var(--cc-surface-alt);
    padding: 40px 20px;
    width: 100%;
    margin-bottom: 0;
}

.coffeecrew-stats-section h2 {
    max-width: 1400px;
    margin: 0 auto 30px;
    color: var(--cc-heading);
    font-size: 28px;
    font-weight: 700;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--cc-accent);
}

.coffeecrew-stats-section .coffeecrew-stats-grid {
    max-width: 1400px;
    margin: 0 auto;
}

.coffeecrew-stats-section .coffeecrew-stat-card {
    background: var(--cc-surface);
    border: 1px solid var(--cc-border-light);
}

.coffeecrew-history-section {
    background: var(--cc-surface);
    padding: 40px 20px;
    width: 100%;
    border-top: 1px solid var(--cc-border-light);
}

.coffeecrew-history-section h2 {
    max-width: 1400px;
    margin: 0 auto 30px;
    color: var(--cc-heading);
    font-size: 28px;
    font-weight: 700;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--cc-accent);
}

.coffeecrew-history-section .coffeecrew-table-controls,
.coffeecrew-history-section .coffeecrew-table-responsive,
.coffeecrew-history-section .coffeecrew-pagination,
.coffeecrew-history-section .coffeecrew-empty-state {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.coffeecrew-table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--cc-surface-alt);
    border-radius: var(--cc-border-radius);
    border: 1px solid var(--cc-border-light);
}

.control-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-left label {
    font-weight: 600;
    margin: 0;
    color: var(--cc-heading);
}

.control-left select {
    padding: 8px 12px;
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-border-radius);
    font-size: 14px;
    cursor: pointer;
    background: var(--cc-surface);
    color: var(--cc-text);
}
.control-left select:hover {
    border-color: var(--cc-accent);
}
.control-left select:focus {
    border-color: var(--cc-accent);
    box-shadow: var(--cc-focus-ring);
}

.coffeecrew-cafeteria-wrapper .control-text,
.coffeecrew-cafeteria-wrapper .control-right {
    color: var(--cc-text);
    font-size: 14px;
    opacity: 0.9;
}

.coffeecrew-table-responsive {
    overflow-x: auto;
    margin-bottom: 20px;
}

.coffeecrew-table-sortable {
    width: 100%;
    border-collapse: collapse;
    background: var(--cc-surface);
    border: 1px solid var(--cc-border-light);
}

.coffeecrew-table-sortable thead {
    background: var(--cc-base);
    color: var(--cc-base-text-on);
}

.coffeecrew-table-sortable th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    position: relative;
    user-select: none;
}

.coffeecrew-table-sortable th.sortable {
    cursor: pointer;
    transition: background 0.2s;
}

.coffeecrew-table-sortable th.sortable:hover {
    background: var(--cc-base-overlay);
}

.coffeecrew-table-sortable th.sortable span {
    margin-right: 5px;
}

.coffeecrew-table-sortable .sort-icon {
    display: inline-block;
    opacity: 0.5;
    font-size: 12px;
    margin-left: 5px;
}

.coffeecrew-table-sortable .sort-icon.active {
    opacity: 1;
    color: var(--cc-accent);
}

.coffeecrew-table-sortable tbody tr {
    border-bottom: 1px solid var(--cc-border-light);
    transition: background 0.2s;
}

.coffeecrew-table-sortable tbody tr:hover {
    background: var(--cc-surface-alt);
}

.coffeecrew-table-sortable td {
    padding: 15px;
    color: var(--cc-text);
}

.coffeecrew-pagination .page-link {
    display: inline-block;
    padding: 8px 12px;
    background: var(--cc-surface);
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-border-radius);
    color: var(--cc-heading);
    text-decoration: none;
    transition: all 0.2s;
    min-width: 40px;
    text-align: center;
}

.coffeecrew-pagination .page-link:hover {
    background: var(--cc-accent-hover);
    color: var(--cc-accent-text-on);
    border-color: var(--cc-accent-hover);
}

.coffeecrew-pagination .page-link.active {
    background: var(--cc-accent);
    color: var(--cc-accent-text-on);
    border-color: var(--cc-accent);
    font-weight: 600;
}

.coffeecrew-cafeteria-wrapper .coffeecrew-empty-state {
    color: var(--cc-text);
    opacity: 0.9;
}

.coffeecrew-empty-state .empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.coffeecrew-empty-state h3 {
    color: var(--cc-heading);
    margin-bottom: 10px;
}

.coffeecrew-empty-state p {
    color: var(--cc-text);
    font-size: 16px;
    opacity: 0.9;
}

/* ===== Utilidades frontend (sustituyen inline) ===== */
.coffeecrew-f-first-use-form {
    background: var(--cc-surface);
    padding: 30px;
    margin: 20px auto;
    max-width: 600px;
    border-radius: var(--cc-border-radius-lg);
    box-shadow: var(--cc-box-shadow);
    border: 1px solid var(--cc-border-light);
}
.coffeecrew-f-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--cc-border);
    border-radius: var(--cc-border-radius);
    background: var(--cc-surface);
    color: var(--cc-text);
}
.coffeecrew-f-input:focus {
    border-color: var(--cc-accent);
    box-shadow: var(--cc-focus-ring);
    outline: none;
}
.coffeecrew-f-section-alt {
    background: var(--cc-surface-alt);
    padding: 40px 20px;
}
.coffeecrew-f-text-muted { color: var(--cc-text); opacity: 0.8; }
.coffeecrew-f-cta-block {
    display: inline-block;
    background: var(--cc-surface);
    color: var(--cc-heading);
    padding: 20px 40px;
    border-radius: var(--cc-border-radius);
    text-decoration: none;
    font-size: 18px;
    font-weight: bold;
    box-shadow: var(--cc-box-shadow);
    transition: transform 0.2s;
    border: 2px solid var(--cc-accent);
}
.coffeecrew-f-cta-block:hover {
    transform: translateY(-2px);
    box-shadow: var(--cc-box-shadow-hover);
}

.coffeecrew-f-heading {
    margin-top: 0;
    color: var(--cc-heading);
}

.coffeecrew-f-btn-block {
    width: 100%;
    padding: 15px;
    font-size: 16px;
}

.coffeecrew-form-message {
    display: none;
    margin-top: 15px;
    padding: 10px;
    border-radius: var(--cc-border-radius);
}

.coffeecrew-alert-success {
    background: var(--cc-success-bg);
    color: var(--cc-success-text);
    padding: 12px 15px;
    border-radius: var(--cc-border-radius);
    border-left: 4px solid var(--cc-success-border);
}

.coffeecrew-alert-danger {
    background: var(--cc-danger-bg);
    color: var(--cc-danger-text);
    padding: 12px 15px;
    border-radius: var(--cc-border-radius);
    border-left: 4px solid var(--cc-danger-border);
}

.coffeecrew-mt-10 { margin-top: 10px; }
.coffeecrew-mt-15 { margin-top: 15px; }
.coffeecrew-mt-20 { margin-top: 20px; }
.coffeecrew-mb-20 { margin-bottom: 20px; }
.coffeecrew-mb-30 { margin-bottom: 30px; }
.coffeecrew-text-center { text-align: center; }

.coffeecrew-hidden { display: none !important; }

/* ===== Element dashboard: QR, PWA, CTA ===== */
.coffeecrew-f-qr-section {
    background: var(--cc-surface);
    padding: 40px 20px;
    text-align: center;
}
.coffeecrew-f-qr-wrap-outer {
    margin-bottom: 30px;
}
.coffeecrew-f-qr-wrap {
    max-width: 300px;
    border: 4px solid var(--cc-border);
    border-radius: var(--cc-border-radius-lg);
    padding: 10px;
    background: var(--cc-surface);
    display: inline-block;
}
/* Add to Home Screen después del registro */
.coffeecrew-add-to-home-promo {
    background: var(--cc-surface-alt);
    border: 1px solid var(--cc-border-light);
    border-radius: var(--cc-border-radius-lg);
    padding: 24px 20px;
    margin-bottom: 24px;
    text-align: center;
    box-shadow: var(--cc-box-shadow);
}
.coffeecrew-add-to-home-promo.coffeecrew-hidden {
    display: none !important;
}
.coffeecrew-a2hs-inner {
    max-width: 420px;
    margin: 0 auto;
}
.coffeecrew-a2hs-icon {
    font-size: 48px;
    margin: 0 0 8px 0;
    line-height: 1;
}
.coffeecrew-a2hs-title {
    font-size: 1.35rem;
    color: var(--cc-heading);
    margin: 0 0 8px 0;
    font-weight: 700;
}
.coffeecrew-a2hs-subtitle {
    font-size: 0.95rem;
    color: var(--cc-text);
    opacity: 0.92;
    margin: 0 0 20px 0;
    line-height: 1.4;
}
.coffeecrew-a2hs-steps {
    text-align: left;
    margin-bottom: 16px;
}
.coffeecrew-a2hs-steps.coffeecrew-hidden {
    display: none !important;
}
.coffeecrew-a2hs-device {
    font-weight: 600;
    margin: 0 0 6px 0;
    font-size: 0.95rem;
}
.coffeecrew-a2hs-list {
    margin: 0 0 0 1.2em;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1.6;
}
.coffeecrew-a2hs-install-btn {
    display: inline-block;
    width: 100%;
    max-width: 280px;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--cc-accent-text-on, #fff);
    background: var(--cc-accent, #8b4513);
    border: none;
    border-radius: var(--cc-border-radius, 8px);
    cursor: pointer;
    margin-bottom: 10px;
    transition: opacity 0.2s, transform 0.15s;
}
.coffeecrew-a2hs-install-btn:hover:not(:disabled) {
    opacity: 0.95;
    transform: scale(1.02);
}
.coffeecrew-a2hs-install-btn:disabled {
    opacity: 0.8;
    cursor: default;
}
.coffeecrew-a2hs-install-btn.coffeecrew-hidden {
    display: none !important;
}
.coffeecrew-a2hs-fallback {
    font-size: 0.9rem;
    color: var(--cc-text);
    opacity: 0.9;
    margin: 0;
}
.coffeecrew-a2hs-fallback.coffeecrew-hidden {
    display: none !important;
}
.coffeecrew-a2hs-desktop {
    font-size: 0.9rem;
    color: var(--cc-text);
    margin: 0 0 16px 0;
}
.coffeecrew-a2hs-desktop.coffeecrew-hidden {
    display: none !important;
}
.coffeecrew-a2hs-dismiss {
    background: transparent;
    border: 1px solid var(--cc-border);
    color: var(--cc-text);
    padding: 10px 20px;
    font-size: 0.9rem;
    border-radius: var(--cc-border-radius, 8px);
    cursor: pointer;
    margin-top: 4px;
}
.coffeecrew-a2hs-dismiss:hover {
    background: var(--cc-surface-alt);
}

.coffeecrew-f-pwa-box {
    background: var(--cc-surface-alt);
    padding: 20px;
    border-radius: var(--cc-border-radius-lg);
    border: 1px solid var(--cc-border-light);
    text-align: left;
    max-width: 500px;
    margin: 0 auto;
}
.coffeecrew-f-pwa-msg {
    font-size: 14px;
    color: var(--cc-text);
    opacity: 0.9;
    max-width: 100%;
    margin: 0;
}
.coffeecrew-f-pwa-msg ol {
    text-align: left;
    padding-left: 20px;
}
.coffeecrew-f-pwa-msg p + p { margin-top: 15px; }
.coffeecrew-f-pwa-msg .coffeecrew-f-pwa-icon { font-size: 20px; }
.coffeecrew-f-cta-section {
    background: var(--cc-base);
    color: var(--cc-base-text-on);
    padding: 40px 20px;
    text-align: center;
}
.coffeecrew-f-cta-section .coffeecrew-f-cta-block {
    background: var(--cc-accent);
    color: var(--cc-accent-text-on);
    border-color: var(--cc-accent);
}
.coffeecrew-f-cta-section .coffeecrew-f-cta-block:hover {
    background: var(--cc-accent-hover);
    border-color: var(--cc-accent-hover);
}
.coffeecrew-f-progress-inner {
    max-width: 600px;
    margin: 0 auto;
}

/* ===== Responsive ===== */
@media screen and (max-width: 768px) {
    .coffeecrew-stats-grid {
        grid-template-columns: 1fr;
    }
    .coffeecrew-action-buttons {
        flex-direction: column;
    }
    .coffeecrew-action-button {
        min-width: 100%;
    }
    .coffeecrew-scan-input {
        flex-direction: column;
    }
    .coffeecrew-nfc-input {
        width: 100%;
    }
    .element-actions {
        flex-direction: column;
    }
    .element-actions button {
        width: 100%;
    }
    .coffeecrew-table {
        font-size: 14px;
    }
    .coffeecrew-table thead {
        display: none;
    }
    .coffeecrew-table tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid var(--cc-border);
        border-radius: var(--cc-border-radius);
    }
    .coffeecrew-table td {
        display: block;
        text-align: right;
        padding: 10px;
        border-bottom: 1px solid var(--cc-border-light);
    }
    .coffeecrew-table td:last-child {
        border-bottom: none;
    }
    .coffeecrew-table td::before {
        content: attr(data-label);
        float: left;
        font-weight: 600;
        color: var(--cc-heading);
    }
    .coffeecrew-user-info {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
}

@media (max-width: 1024px) {
    .coffeecrew-stats-section .coffeecrew-stats-grid,
    .coffeecrew-history-section h2,
    .coffeecrew-history-section .coffeecrew-table-controls,
    .coffeecrew-history-section .coffeecrew-table-responsive,
    .coffeecrew-history-section .coffeecrew-pagination {
        max-width: 100%;
        padding: 0 15px;
    }
}

@media (max-width: 768px) {
    .coffeecrew-welcome-section {
        padding: 30px 20px;
    }
    .coffeecrew-welcome-section .welcome-title {
        font-size: 24px;
    }
    .coffeecrew-welcome-section .welcome-subtitle {
        font-size: 16px;
    }
    .coffeecrew-stats-section {
        padding: 30px 15px;
    }
    .coffeecrew-stats-section h2 {
        font-size: 22px;
        padding: 0 15px;
    }
    .coffeecrew-history-section {
        padding: 30px 15px;
    }
    .coffeecrew-history-section h2 {
        font-size: 22px;
        padding: 0 15px;
    }
    .coffeecrew-table-controls {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    .control-right {
        width: 100%;
        text-align: center;
    }
    .coffeecrew-table-sortable {
        font-size: 14px;
    }
    .coffeecrew-table-sortable th,
    .coffeecrew-table-sortable td {
        padding: 10px 8px;
    }
    .coffeecrew-table-sortable thead {
        display: none;
    }
    .coffeecrew-table-sortable tbody tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid var(--cc-border);
        border-radius: var(--cc-border-radius);
        padding: 10px;
    }
    .coffeecrew-table-sortable td {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border: none;
    }
    .coffeecrew-table-sortable td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--cc-heading);
    }
    .coffeecrew-renewal-notice {
        flex-direction: column;
        text-align: center;
        padding: 20px;
        margin: 20px 15px;
    }
    .coffeecrew-renewal-notice .renewal-icon {
        font-size: 48px;
    }
    .coffeecrew-renewal-notice .renewal-title {
        font-size: 20px;
    }
    .coffeecrew-renewal-notice .renewal-message {
        font-size: 14px;
    }
    .coffeecrew-renewal-notice .renewal-button {
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.coffeecrew-element-info,
.coffeecrew-purchase-result {
    animation: fadeIn 0.4s ease;
}

.coffeecrew-stat-card {
    animation: slideIn 0.3s ease;
}
