/* Reset y base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Footer */
footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 3rem;
}

footer p {
    margin: 0;
}

/* Main content */
main {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.user-card {
    text-align: center;
    padding: 2rem;
}

.user-card h2 {
    color: #667eea;
    margin-bottom: 0.5rem;
}

.username {
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

/* Estadísticas */
.stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-top: 2rem;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2.5rem;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    display: block;
    color: #666;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Stats Grid (Admin) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
    text-transform: uppercase;
    margin-top: 0.5rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.badge-ok {
    background: #d4edda;
    color: #155724;
}

.badge-inactive {
    background: #f8d7da;
    color: #721c24;
}

.badge-not_found {
    background: #fff3cd;
    color: #856404;
}

.badge-active {
    background: #d4edda;
    color: #155724;
}

.status-active {
    color: #28a745;
    font-weight: bold;
}

.status-inactive {
    color: #dc3545;
    font-weight: bold;
}

/* Botones */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
}

.btn:hover {
    background: #5568d3;
}

.btn-primary {
    background: #667eea;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #666;
    font-size: 0.85rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

/* Tablas */
.table-responsive {
    overflow-x: auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.admin-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.admin-table tr:hover {
    background: #f8f9fa;
}

.admin-table code {
    background: #f4f4f4;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.9rem;
}

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-card h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 0.5rem;
    font-size: 2rem;
}

.login-card h2 {
    text-align: center;
    color: #666;
    margin-bottom: 2rem;
    font-size: 1.3rem;
    font-weight: normal;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: #666;
}

/* Admin navigation */
.admin-nav {
    background: #2c3e50;
    padding: 1rem 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.admin-nav .container {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.admin-nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: background 0.3s;
}

.admin-nav a:hover {
    background: rgba(255,255,255,0.1);
}

/* Dropdown en navegación */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    cursor: pointer;
    user-select: none;
}

.nav-dropdown-menu {
    display: none !important;
    position: absolute;
    top: 100%;
    left: 0;
    background: #34495e;
    min-width: 200px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    margin-top: 0;
    padding-top: 0.5rem;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.nav-dropdown:hover .nav-dropdown-menu {
    display: block !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.nav-dropdown-menu a {
    display: block;
    padding: 0.75rem 1rem;
    border-radius: 0;
}

.nav-dropdown-menu a:first-child {
    border-radius: 6px 6px 0 0;
}

.nav-dropdown-menu a:last-child {
    border-radius: 0 0 6px 6px;
}

.nav-dropdown-menu a:hover {
    background: rgba(255,255,255,0.15);
}

/* Breadcrumbs */
.breadcrumbs {
    background: #ecf0f1;
    padding: 0.75rem 0;
    border-bottom: 1px solid #bdc3c7;
}

.breadcrumbs .container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    position: relative;
}

.breadcrumb-version {
    position: absolute;
    right: 0;
    color: #95a5a6;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    background: white;
    user-select: none;
}

.breadcrumb-item {
    color: #7f8c8d;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb-item:hover {
    color: #2c3e50;
}

.breadcrumb-item.active {
    color: #2c3e50;
    font-weight: 600;
}

.breadcrumb-separator {
    color: #95a5a6;
    user-select: none;
}

.admin-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-top: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.admin-container h1 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
}

.admin-container h2 {
    color: #495057;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.welcome-msg {
    background: #e7f3ff;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border-left: 4px solid #667eea;
}

.quick-actions {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.quick-actions h2 {
    margin-top: 0;
    margin-bottom: 1rem;
}

.quick-actions .btn {
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Staff view */
.staff-view {
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.staff-info {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid #eee;
}

.staff-info h3 {
    color: #495057;
    margin-bottom: 1rem;
}

/* Error pages */
.error-page {
    text-align: center;
    padding: 3rem 1rem;
}

.error-page h2 {
    color: #dc3545;
    font-size: 2rem;
    margin-bottom: 1rem;
}

/* ========================================
   SISTEMA DE TICKETS V1.1.0
   ======================================== */

/* Badges de estado */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
}

.badge-status-abierto { background: #d4edda; color: #155724; }
.badge-status-cerrado { background: #d1ecf1; color: #0c5460; }
.badge-status-cerrado_permanente { background: #f8d7da; color: #721c24; }

.badge-priority-baja { background: #e2e3e5; color: #383d41; }
.badge-priority-media { background: #fff3cd; color: #856404; }
.badge-priority-alta { background: #ffeaa7; color: #d63031; }
.badge-priority-critica { background: #ff7675; color: white; }

.badge-error { background: #f8d7da; color: #721c24; }
.badge-idea { background: #cfe2ff; color: #084298; }
.badge-consulta { background: #fff3cd; color: #856404; }
.badge-sugerencia { background: #d1e7dd; color: #0f5132; }
.badge-queja { background: #f8d7da; color: #842029; }

.badge-admin { background: #667eea; color: white; }
.badge-staff { background: #764ba2; color: white; }

.badge-owner { background: #3498db; color: white; }
.badge-assignee { background: #2ecc71; color: white; }
.badge-observer { background: #95a5a6; color: white; }

.badge-internal { background: #e67e22; color: white; }

/* Vista de conversación - Thread */
.ticket-thread-container {
    max-width: 1400px;
    margin: 0 auto;
}

.ticket-header {
    margin-bottom: 2rem;
}

.ticket-header h2 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.ticket-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.ticket-id {
    font-weight: bold;
    color: #7f8c8d;
}

.ticket-info p {
    margin: 0.5rem 0;
    color: #555;
}

.ticket-controls {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #ecf0f1;
}

.control-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.inline-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.inline-form label {
    font-weight: 600;
    color: #555;
}

.inline-form select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Layout de conversación */
.ticket-body {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2rem;
    margin-top: 2rem;
}

@media (max-width: 1024px) {
    .ticket-body {
        grid-template-columns: 1fr;
    }
}

/* Conversación */
.ticket-conversation h3 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
    max-height: 600px;
    overflow-y: auto;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.message {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message-own {
    border-left: 4px solid #667eea;
}

.message-other {
    border-left: 4px solid #95a5a6;
}

.message-internal {
    background: #fff3cd;
    border-left: 4px solid #e67e22;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.message-header strong {
    color: #2c3e50;
}

.message-time {
    font-size: 0.85rem;
    color: #95a5a6;
}

.message-body {
    color: #555;
    line-height: 1.6;
}

/* Formulario de mensaje */
.message-form {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.message-form h4 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.message-form textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
}

.message-form .form-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Sidebar de participantes */
.ticket-sidebar .card {
    position: sticky;
    top: 20px;
}

.ticket-sidebar h4, .ticket-sidebar h5 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.participants-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.participants-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid #ecf0f1;
}

.participants-list li:last-child {
    border-bottom: none;
}

.participant-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.btn-icon:hover {
    opacity: 1;
}

.add-participant {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #ecf0f1;
}

.add-participant select {
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Alertas */
.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Botones */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-link {
    background: none;
    border: none;
    color: #667eea;
    text-decoration: none;
    cursor: pointer;
    padding: 0.5rem 0;
}

.btn-link:hover {
    text-decoration: underline;
}

/* User container */
.user-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 0;
}

.ticket-breadcrumb {
    margin-bottom: 1.5rem;
}

.ticket-breadcrumb a {
    color: #667eea;
    text-decoration: none;
}

.ticket-breadcrumb a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .stats {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .admin-nav .container {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .admin-nav a {
        display: block;
    }
    
    .quick-actions .btn {
        display: block;
        margin-bottom: 0.5rem;
        text-align: center;
    }
}

/* Estilos para Sistema de Voluntariado */
.badge-warning {
    background: #ffc107;
    color: #000;
}

.badge-success {
    background: #28a745;
    color: white;
}

.badge-secondary {
    background: #6c757d;
    color: white;
}

/* Autocompletado de usuarios */
.autocomplete-wrapper {
    position: relative;
    flex: 1;
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
}

.autocomplete-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.autocomplete-item:hover {
    background: #f8f9fa;
}

.autocomplete-item strong {
    display: block;
    color: #333;
    margin-bottom: 3px;
}

.autocomplete-item small {
    color: #666;
    font-size: 0.85em;
}

.add-participant form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
}

.add-participant .form-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.add-participant input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
}

.add-participant input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.add-participant select {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.add-participant button {
    white-space: nowrap;
}

.add-participant .btn-block {
    width: 100%;
    margin-top: 5px;
}

.add-participant h5 {
    margin-bottom: 12px;
    color: #555;
    font-size: 0.95em;
    font-weight: 600;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

/* Tabla cebrada - filas alternadas */
.data-table tbody tr:nth-child(even) {
    background-color: #e9ecef;
}

.data-table tbody tr:nth-child(odd) {
    background-color: #ffffff;
}

.data-table tbody tr:hover {
    background-color: #dee2e6;
}
