* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 1100px; /* Wider for desktop */
    padding: 30px;
}

.form-container {
    background: white;
    border-radius: 16px;
    padding: 40px 48px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.12);
    display: none;
    animation: fadeIn 0.4s ease-in;
    max-width: 960px; /* Centered readable width */
    margin: 0 auto;
}

.form-container.active {
    display: block;
}

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

.form-header {
    text-align: center;
    margin-bottom: 30px;
}

.form-header h1 {
    color: #667eea;
    font-size: 2.8rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.form-header .logo-img {
    width: 250px;
    height: auto;
    margin: 0 auto 10px;
    display: block;
}

.header-top .logo-img {
    width: 180px;
    height: auto;
}

.form-header h2 {
    color: #333;
    font-size: 1.5rem;
    font-weight: 300;
}

/* Header top: Title + right actions */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 500;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.input-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
}

.btn-secondary {
    padding: 10px 20px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-secondary:hover {
    background: #5a6268;
}

.form-switch {
    text-align: center;
    margin-top: 20px;
    color: #666;
}

.form-switch a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.form-switch a:hover {
    text-decoration: underline;
}

.pending-message {
    text-align: center;
    padding: 20px;
}

.pending-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.pending-message p {
    margin-bottom: 15px;
    color: #666;
    line-height: 1.6;
}

.dashboard-content {
    padding: 10px 0 24px 0;
}

.user-info {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.user-info p {
    margin-bottom: 10px;
    color: #333;
}

.status-active {
    color: #28a745;
    font-weight: 600;
}

.admin-panel {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.admin-panel h3 {
    color: #856404;
    margin-bottom: 15px;
}

.admin-section h4 {
    color: #333;
    margin-bottom: 10px;
}

/* Users toolbar (search and filters) */
.users-toolbar {
    display: grid;
    grid-template-columns: 1fr 220px 220px 120px;
    gap: 12px;
    align-items: center;
    margin: 8px 0 18px 0;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.users-toolbar input,
.users-toolbar select {
    padding: 10px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.users-toolbar input:focus,
.users-toolbar select:focus {
    border-color: #667eea;
}

/* Records toolbar (search and filters) */
.records-toolbar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 8px 0 18px 0;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.filters-row-1,
.filters-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    align-items: center;
}

.records-toolbar input,
.records-toolbar select {
    padding: 10px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.records-toolbar input:focus,
.records-toolbar select:focus {
    border-color: #667eea;
}

.pending-request {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
}

.pending-request h5 {
    color: #333;
    margin-bottom: 5px;
}

.pending-request p {
    color: #666;
    font-size: 14px;
    margin-bottom: 10px;
}

.request-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px; /* Añadido para separar de la lista desplegable */
}

.request-actions .btn-approve,
.request-actions .btn-reject {
    flex-grow: 1; /* Hace que los botones ocupen el espacio disponible */
    padding: 10px;
    font-size: 14px;
}

.btn-approve {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
}

.btn-reject {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
}

.user-actions {
    text-align: center;
    margin-top: 20px;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
}

.message {
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
}

.message.success {
    background: #28a745;
}

.message.error {
    background: #dc3545;
}

.message.info {
    background: #17a2b8;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .form-container {
        padding: 30px 20px;
    }
    
    .form-header h1 {
        font-size: 2rem;
    }
}

/* Admin Menu Styles */
.admin-menu {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.btn-menu {
    width: 100%;
    padding: 15px;
    background-color: #f8f9fa;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s ease;
}

.btn-menu:hover {
    background-color: #e9ecef;
    border-color: #667eea;
}

.btn-back {
    margin-top: 20px;
}

/* Companies List Styles */
.company-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.company-item p {
    font-weight: 500;
}

.company-actions button {
    margin-left: 10px;
    font-size: 12px;
    padding: 5px 10px;
}

/* Add company dropdown to user request */
.request-actions .company-select-group {
    margin-top: 10px;
}

.request-actions select {
    width: 100%;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #dee2e6;
}

/* Users management list */
#usersList {
    background: white;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-top: 24px;
    overflow: hidden;
}

.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    background: #ffffff;
    border-bottom: 1px solid #f1f3f4;
    transition: background-color 0.2s ease;
}

.user-item:hover {
    background: #f8f9fa;
}

.user-item:last-child {
    border-bottom: none;
}

.user-main {
    flex: 1;
}

.user-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.user-email {
    color: #6c757d;
    font-weight: 400;
}

.user-meta {
    color: #495057;
    font-size: 14px;
}

.user-actions {
    display: flex;
    gap: 10px;
}

#userEditSection {
    border: 2px solid #667eea;
    border-radius: 8px;
    background-color: #f8f9ff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Grid helpers */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.grid-4 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 16px;
}

/* Uploads */
.upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.upload-item {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    text-align: center;
    min-height: 180px;
    transition: all 0.3s ease;
}

.upload-item:hover {
    border-color: #667eea;
    background: #f0f2ff;
}

.upload-item label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 4px;
}

.upload-item input[type="file"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 12px;
}

.upload-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.thumb {
    width: 100%;
    max-height: 120px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    display: none; /* hidden until preview loaded */
    margin-top: 8px;
}

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .upload-grid { 
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
    .container {
        max-width: 100%;
        padding: 15px;
    }
    .form-container {
        padding: 25px 20px;
        margin: 0;
    }
    .filters-row-1,
    .filters-row-2 {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
}

/* Records List Styles */
#recordsList {
    background: white;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-top: 24px;
    overflow: hidden;
}

.record-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    background: #ffffff;
    border-bottom: 1px solid #f1f3f4;
    transition: background-color 0.2s ease;
}

.record-item:hover {
    background: #f8f9fa;
}

.record-item:last-child {
    border-bottom: none;
}

.record-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.record-title {
    font-weight: 600;
    color: #333;
    font-size: 16px;
}

.record-details {
    color: #6c757d;
    font-size: 14px;
}

.record-actions {
    display: flex;
    gap: 8px;
}

.record-actions button {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.record-actions .btn-edit {
    background: #6c757d;
    color: white;
    border: none;
}

.record-actions .btn-edit:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.record-actions .btn-delete {
    background: #dc3545;
    color: white;
    border: none;
}

.record-actions .btn-delete:hover {
    background: #c82333;
    transform: translateY(-1px);
}

/* Section Headers */
.admin-section h4 {
    color: #333;
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 600;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
}

/* Tabs System */
.tabs-container {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #6c757d;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: #667eea;
    background: #f8f9fa;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

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

/* Detail Header */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e9ecef;
}

.detail-header h4 {
    margin: 0;
    padding: 0;
    border: none;
}

/* Operation Item */
.operation-item {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.operation-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
}

.operation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.operation-number {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.operation-type-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.operation-type-badge.importacion {
    background: #d1ecf1;
    color: #0c5460;
}

.operation-type-badge.exportacion {
    background: #d4edda;
    color: #155724;
}

.operation-status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.operation-status-badge.activa {
    background: #d4edda;
    color: #155724;
}

.operation-status-badge.cerrada {
    background: #f8d7da;
    color: #721c24;
}

/* Switch Toggle Styles */
.switch-container {
    display: flex;
    align-items: center;
    margin-top: 8px;
}

.switch-input {
    display: none;
}

.switch-label {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 180px;
    height: 40px;
    background: #f8d7da;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid #e1e5e9;
}

.switch-input:checked + .switch-label {
    background: #d4edda;
}

.switch-slider {
    position: absolute;
    left: 4px;
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch-input:checked + .switch-label .switch-slider {
    transform: translateX(140px);
}

.switch-text {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px 0 45px;
    font-size: 14px;
    font-weight: 600;
}

.switch-text-on {
    color: #155724;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.switch-text-off {
    color: #721c24;
    opacity: 1;
    transition: opacity 0.3s ease;
    margin-left: auto;
}

.switch-input:checked + .switch-label .switch-text-on {
    opacity: 1;
}

.switch-input:checked + .switch-label .switch-text-off {
    opacity: 0;
}

/* Language Selector Styles */
.language-selector {
    padding: 8px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 10px;
}

.language-selector:hover {
    border-color: #667eea;
    background: #f8f9fa;
}

.language-selector:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.operation-details {
    color: #6c757d;
    font-size: 14px;
    line-height: 1.6;
}

.operation-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* Driver Item */
.driver-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.driver-header-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.driver-info-inline {
    flex: 0 0 auto;
}

.driver-info-inline h6 {
    margin: 0 0 4px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.driver-info-inline p {
    margin: 0;
    color: #6c757d;
    font-size: 14px;
}

.driver-photos-inline {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

.driver-thumb-inline {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid #dee2e6;
    cursor: pointer;
    transition: all 0.2s ease;
}

.driver-thumb-inline:hover {
    border-color: #667eea;
    transform: scale(1.05);
}

.driver-actions-inline {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.driver-actions-inline button {
    white-space: nowrap;
}

/* Container Item */
.container-item {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.container-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.container-number {
    font-weight: 600;
    color: #333;
    font-size: 16px;
}

.container-actions {
    display: flex;
    gap: 8px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-in;
}

.modal-content {
    background-color: #fff;
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 32px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.2s ease;
}

.modal-close:hover {
    transform: scale(1.2);
}

.modal form {
    padding: 24px;
}

.info-box {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.info-box h4 {
    margin: 0 0 12px 0;
    color: #495057;
    font-size: 16px;
    font-weight: 600;
}

.info-box p {
    margin: 4px 0;
    color: #6c757d;
    font-size: 14px;
}

@media (max-width: 768px) {
    .grid-4 { grid-template-columns: 1fr; }
    .upload-grid { 
        grid-template-columns: 1fr 1fr;
    }
    .upload-item {
        min-height: 140px;
        padding: 12px;
    }
    .users-toolbar {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 16px;
    }
    .filters-row-1,
    .filters-row-2 {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .records-toolbar {
        padding: 16px;
    }
    
    .record-item {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
    }
    
    .record-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .tabs-container {
        flex-direction: column;
        gap: 0;
    }
    
    .tab-btn {
        text-align: left;
        border-bottom: 1px solid #e9ecef;
        border-left: 3px solid transparent;
        margin-bottom: 0;
        margin-left: -2px;
    }
    
    .tab-btn.active {
        border-bottom-color: #e9ecef;
        border-left-color: #667eea;
    }
    
    .operation-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
    
    .modal form {
        padding: 16px;
    }
}
