/* =====================================================
   ADMIN DASHBOARD - Estilos
   ===================================================== */

.admin-body {
    background: var(--gray-100);
}

.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--dark);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header .logo {
    font-size: 1.25rem;
}

.sidebar-header .logo svg {
    color: var(--primary);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--gray-400);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 500;
    font-size: 0.875rem;
}

.client-name {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

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

.section-header h1 {
    font-size: 1.75rem;
    color: var(--dark);
}

.section-header p {
    color: var(--gray-500);
    margin-top: 4px;
}

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

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.total { background: #e0e7ff; color: #4338ca; }
.stat-icon.pending { background: #fef3c7; color: #b45309; }
.stat-icon.transit { background: #dbeafe; color: #1d4ed8; }
.stat-icon.delivered { background: #d1fae5; color: #059669; }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* Shipments Table */
.shipments-table-container {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.shipments-table th,
.shipments-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.shipments-table th {
    background: var(--gray-100);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-600);
    text-transform: uppercase;
}

.shipments-table tr:hover {
    background: var(--gray-50);
}

.shipments-table .tracking-code {
    font-family: monospace;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
}

.shipments-table .tracking-code:hover {
    text-decoration: underline;
}

/* Filters */
.filters {
    margin-bottom: 20px;
}

.filter-select {
    padding: 10px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 0.875rem;
    background: white;
    cursor: pointer;
}

/* Form Card */
.form-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
}

.form-section {
    margin-bottom: 32px;
}

.form-section h3 {
    font-size: 1.125rem;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--dark);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark);
    font-size: 0.875rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
    padding: 4px 8px;
}

.modal-close:hover {
    color: var(--dark);
}

.modal-body {
    padding: 24px;
}

/* Modal Detail */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.detail-item {
    padding: 12px;
    background: var(--gray-100);
    border-radius: 8px;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.detail-item .label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.detail-item .value {
    font-weight: 500;
    color: var(--dark);
}

/* Update Status Form */
.update-status-form {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

.update-status-form h4 {
    margin-bottom: 16px;
    color: var(--dark);
}

.update-status-form .form-grid {
    gap: 12px;
}

/* Loading */
.loading {
    padding: 40px;
    text-align: center;
    color: var(--gray-500);
}

/* Empty State */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--gray-500);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--dark);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: slideIn 0.3s ease;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

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

/* Templates Grid */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.template-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.template-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.template-card.inactive {
    opacity: 0.6;
}

.template-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.template-card-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--dark);
}

.template-card-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.template-card-status.active {
    background: #d1fae5;
    color: #065f46;
}

.template-card-status.inactive {
    background: #f3f4f6;
    color: #6b7280;
}

.template-card-subject {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.template-card-trigger {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.template-card-trigger span {
    background: var(--gray-200);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Template Editor */
.template-help {
    margin-bottom: 8px;
}

.template-help code {
    background: var(--gray-200);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

#template_html {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Preview Modal */
.modal-large {
    max-width: 900px;
}

.preview-subject {
    padding: 12px 16px;
    background: var(--gray-100);
    border-radius: 8px;
    margin-bottom: 16px;
}

.preview-frame {
    width: 100%;
    height: 500px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    background: white;
}

/* Send Email Button */
.btn-send-email {
    background: #8b5cf6;
    color: white;
}

.btn-send-email:hover {
    background: #7c3aed;
}

.btn-secondary {
    background: var(--gray-600);
    color: white;
}

.btn-secondary:hover {
    background: var(--gray-700);
}

/* Action Buttons in Table */
.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-icon {
    padding: 8px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon.btn-email {
    background: #ede9fe;
    color: #7c3aed;
}

.btn-icon.btn-email:hover {
    background: #ddd6fe;
}

.btn-icon.btn-view {
    background: #e0e7ff;
    color: #4338ca;
}

.btn-icon.btn-view:hover {
    background: #c7d2fe;
}

/* =====================================================
   COMPANIES SECTION
   ===================================================== */

#section-companies {
    width: 100%;
}

#section-companies .table-container {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    width: 100%;
    overflow-x: auto;
}

#section-companies .data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

#section-companies .data-table th,
#section-companies .data-table td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
}

#section-companies .data-table th:nth-child(1),
#section-companies .data-table td:nth-child(1) { width: 25%; }
#section-companies .data-table th:nth-child(2),
#section-companies .data-table td:nth-child(2) { width: 22%; }
#section-companies .data-table th:nth-child(3),
#section-companies .data-table td:nth-child(3) { width: 13%; }
#section-companies .data-table th:nth-child(4),
#section-companies .data-table td:nth-child(4) { width: 15%; }
#section-companies .data-table th:nth-child(5),
#section-companies .data-table td:nth-child(5) { width: 10%; }
#section-companies .data-table th:nth-child(6),
#section-companies .data-table td:nth-child(6) { width: 15%; text-align: right; }

#section-companies .data-table th {
    background: var(--gray-100);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#section-companies .data-table tbody tr:hover {
    background: var(--gray-50);
}

#section-companies .data-table tbody tr:last-child td {
    border-bottom: none;
}

.company-name {
    display: flex;
    align-items: center;
    gap: 10px;
}

.company-name svg {
    color: var(--primary);
    flex-shrink: 0;
}

.company-name strong {
    color: var(--dark);
}

#section-companies .data-table td a {
    color: var(--primary);
    text-decoration: none;
}

#section-companies .data-table td a:hover {
    text-decoration: underline;
}

#section-companies .btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#section-companies .action-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

#section-companies .empty,
#section-companies .loading,
#section-companies .error {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
}

/* Company Users Modal Table */
#companyUsersModal .data-table {
    width: 100%;
    border-collapse: collapse;
}

#companyUsersModal .data-table th,
#companyUsersModal .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

#companyUsersModal .data-table th {
    background: var(--gray-100);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--gray-600);
    text-transform: uppercase;
}

#companyUsersModal .action-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

    .main-content {
        margin-left: 0;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .templates-grid {
        grid-template-columns: 1fr;
    }
}
