/**
 * Estilos comunes - Control de Cupones
 * Incluye: reset, tipografía, header, botones, badges, toasts, modales, formularios
 */

/* Reset y base */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

/* Header estándar */
.header {
    background: linear-gradient(135deg, #1a73e8, #0d47a1);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header h1 { font-size: 1.5em; font-weight: 600; }
.header-nav { display: flex; gap: 15px; align-items: center; }
.header-nav a { color: white; text-decoration: none; font-size: 0.9em; opacity: 0.9; }
.header-nav a:hover { opacity: 1; text-decoration: underline; }
.header-link {
    color: white;
    text-decoration: none;
    background: rgba(255,255,255,0.2);
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9em;
    transition: background 0.2s;
}
.header-link:hover { background: rgba(255,255,255,0.3); }

/* User info en header */
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.15);
    padding: 8px 16px;
    border-radius: 20px;
}
.user-info .name { font-weight: 600; }
.user-info .role { font-size: 0.8em; opacity: 0.8; }

/* Container */
.container { max-width: 1200px; margin: 30px auto; padding: 0 20px; }
.container-wide { max-width: 1400px; }
.container-narrow { max-width: 1000px; }

/* Botones */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-primary { background: #1a73e8; color: white; }
.btn-primary:hover { background: #1557b0; }
.btn-secondary { background: #f0f0f0; color: #333; }
.btn-secondary:hover { background: #e0e0e0; }
.btn-danger { background: #d93025; color: white; }
.btn-danger:hover { background: #b3261e; }
.btn-success { background: #137333; color: white; }
.btn-success:hover { background: #0d5c28; }
.btn-logout {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
}
.btn-logout:hover { background: rgba(255,255,255,0.3); }
.btn-sm { padding: 6px 12px; font-size: 0.85em; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-header h2, .card-header h3 { font-size: 1.2em; font-weight: 600; }
.card-body { padding: 20px 24px; }

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}
.badge-primary { background: #e8f0fe; color: #1a73e8; }
.badge-success { background: #e6f4ea; color: #137333; }
.badge-warning { background: #fef7e0; color: #e37400; }
.badge-danger { background: #fce8e6; color: #d93025; }
.badge-admin { background: #e8f0fe; color: #1a73e8; }
.badge-operario { background: #fef7e0; color: #e37400; }
.badge-activo { background: #e6f4ea; color: #137333; }
.badge-inactivo { background: #fce8e6; color: #d93025; }

/* Formularios */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.85em;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95em;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}
.form-group small { color: #888; font-size: 0.8em; margin-top: 4px; display: block; }

/* Tablas */
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.85em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e0e0e0;
    background: #f8f9fa;
}
td { padding: 14px 16px; border-bottom: 1px solid #f0f0f0; }
tr:hover { background: #f8fbff; }
.code-cell { font-family: 'Courier New', monospace; font-weight: 600; letter-spacing: 1px; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 1.1em; margin: 0; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #999;
    line-height: 1;
}
.modal-close:hover { color: #333; }
.modal-body { padding: 20px 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 2000;
    animation: toastIn 0.3s ease;
    max-width: 400px;
}
.toast.success { background: #137333; }
.toast.error { background: #d93025; }
.toast.info { background: #1a73e8; }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Loading / Spinner */
.loading { text-align: center; padding: 40px; color: #888; display: none; }
.loading.active { display: block; }
.spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #ddd;
    border-top-color: #1a73e8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}
.empty-state .icon { font-size: 3em; margin-bottom: 10px; }

/* Responsive */
@media (max-width: 768px) {
    .header { padding: 15px; flex-wrap: wrap; gap: 10px; }
    .header h1 { font-size: 1.2em; }
    .header-nav { flex-wrap: wrap; gap: 10px; }
    .container { padding: 0 10px; }
}
