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

:root {
    --primary-red: #C13832;
    --primary-green: #2D5F3F;
    --bg-light: #F5F5F5;
    --bg-cream: #F5F1ED;
    --text-dark: #1A1A1A;
    --text-gray: #666666;
    --border-color: #E0E0E0;
    --success: #4A7C59;
    --warning: #F59E0B;
    --danger: #C13832;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-cream) 0%, var(--bg-light) 100%);
}

.login-container {
    background: white;
    padding: 48px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 420px;
}

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

.logo-backoffice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}

.logo-backoffice h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-green);
}

.login-header h2 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-gray);
    font-size: 14px;
}

.login-form {
    margin-bottom: 24px;
}

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s ease;
}

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

.btn-login {
    width: 100%;
    padding: 14px;
    background-color: var(--primary-green);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-login:hover {
    background-color: #234A31;
    transform: translateY(-1px);
}

.error-message {
    margin-top: 16px;
    padding: 12px;
    background-color: #FFEBEE;
    color: var(--danger);
    border-radius: 6px;
    font-size: 14px;
}

.login-footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.login-footer p {
    font-size: 13px;
    color: var(--text-gray);
}

.login-footer code {
    background-color: var(--bg-light);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

/* ===== DASHBOARD ===== */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-green);
}

.sidebar-nav {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 16px 16px 8px 16px;
    margin-top: 8px;
}

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

.nav-item:hover {
    background-color: var(--bg-light);
    color: var(--text-dark);
}

.nav-item.active {
    background-color: #E8F5E9;
    color: var(--primary-green);
    font-weight: 500;
}

/* Expandable nav items */
.nav-item-group {
    margin-bottom: 4px;
}

.nav-item-expandable {
    position: relative;
    cursor: pointer;
}

.nav-item-expandable .expand-icon {
    margin-left: auto;
    transition: transform 0.3s ease;
}

.nav-item-expandable.expanded .expand-icon {
    transform: rotate(180deg);
}

.nav-submenu {
    padding-left: 20px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

/* Nested submenu (e.g., Tramitación → Fases) */
.nav-submenu.nav-submenu-nested {
    padding-left: 16px;
    margin-left: 12px;
    border-left: 1px solid rgba(0, 0, 0, 0.06);
}

.nav-subitem {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--text-gray);
    text-decoration: none;
    border-radius: 6px;
    margin-bottom: 2px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.nav-subitem:hover {
    background-color: var(--bg-light);
    color: var(--text-dark);
}

.nav-subitem.active {
    background-color: #E8F5E9;
    color: var(--primary-green);
    font-weight: 500;
}

/* Phases grid */
.phases-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.phase-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    transition: all 0.2s ease;
}

.phase-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.phase-card h3 {
    margin: 0 0 16px 0;
    color: var(--text-dark);
    font-size: 18px;
    font-weight: 600;
}

.phase-card .phase-count {
    font-size: 32px;
    font-weight: bold;
    color: var(--primary-green);
    margin: 16px 0;
}

.phase-card .btn-secondary {
    margin-top: 12px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.btn-logout {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background-color: transparent;
    color: var(--text-gray);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background-color: #FFEBEE;
    color: var(--danger);
    border-color: var(--danger);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.top-bar {
    background-color: white;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-bar h1 {
    font-size: 24px;
    font-weight: 600;
}

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

.user-info span {
    font-size: 14px;
    color: var(--text-gray);
}

/* Pages */
.page {
    display: none;
    padding: 32px;
}

.page.active {
    display: block;
}

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

.stat-card {
    background-color: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 16px;
}

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

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

.stat-label {
    font-size: 13px;
    color: var(--text-gray);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-dark);
}

/* Table */
.table-container {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

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

.table-header h3 {
    font-size: 18px;
    font-weight: 600;
}

/* Filters */
.filters-container {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
    background-color: var(--bg-light);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
}

.filter-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-gray);
}

.filter-select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-select:hover {
    border-color: var(--primary-red);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(193, 56, 50, 0.1);
}

.btn-secondary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background-color: var(--bg-light);
    color: var(--text-dark);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background-color: #E0E0E0;
}

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

.data-table thead {
    background-color: var(--bg-light);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-gray);
    text-transform: uppercase;
}

.data-table td {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
}

.data-table tbody tr:hover {
    background-color: var(--bg-cream);
}

.data-table td.loading {
    text-align: center;
    color: var(--text-gray);
    padding: 40px;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background-color: #E8F5E9;
    color: var(--success);
}

.badge-warning {
    background-color: #FFF3E0;
    color: var(--warning);
}

.badge-warning-alt {
    background-color: #FFF9C4;
    color: #F57F17;
    border: 1px solid #FBC02D;
}

.badge-danger {
    background-color: #FFEBEE;
    color: var(--danger);
}

.badge-info {
    background-color: #E3F2FD;
    color: #1976D2;
}

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

.btn-icon {
    padding: 6px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background-color: var(--bg-light);
}

.btn-icon.primary:hover {
    background-color: #E3F2FD;
    border-color: #1976D2;
    color: #1976D2;
}

.btn-icon.success:hover {
    background-color: #E8F5E9;
    border-color: var(--success);
    color: var(--success);
}

.btn-icon.warning {
    border-color: #FF9800;
    color: #FF9800;
}

.btn-icon.warning:hover {
    background-color: #FFF3E0;
    border-color: #F57C00;
    color: #F57C00;
}

.btn-icon.danger:hover {
    background-color: #FFEBEE;
    border-color: var(--danger);
    color: var(--danger);
}

/* Config Page */
.config-container {
    max-width: 800px;
}

.config-section {
    background-color: white;
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
}

.config-section h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.section-description {
    color: var(--text-gray);
    font-size: 14px;
    margin-bottom: 24px;
}

/* Logo Upload Section */
.logo-upload-section {
    display: flex;
    gap: 32px;
    align-items: flex-start;
    margin-top: 24px;
}

.logo-preview {
    flex: 0 0 200px;
    height: 200px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-light);
    overflow: hidden;
}

.logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.logo-placeholder {
    text-align: center;
    color: var(--text-gray);
}

.logo-placeholder svg {
    margin-bottom: 12px;
}

.logo-placeholder p {
    font-size: 14px;
    margin: 0;
}

.logo-upload-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.logo-upload-controls small {
    color: var(--text-gray);
    font-size: 13px;
}

.config-form .form-group {
    margin-bottom: 24px;
}

.config-form small {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-gray);
}

.btn-primary {
    padding: 12px 24px;
    background-color: var(--primary-green);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background-color: #234A31;
    transform: translateY(-1px);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-gray);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background-color: var(--bg-light);
}

.modal-body {
    padding: 24px;
}

/* ===== LANGUAGES PAGE ===== */
.language-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}

.lang-tab {
    background: none;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-gray);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    bottom: -2px;
}

.lang-tab:hover {
    color: var(--text-dark);
    background-color: rgba(193, 56, 50, 0.05);
}

.lang-tab.active {
    color: var(--primary-red);
    border-bottom-color: var(--primary-red);
    font-weight: 600;
}

.translations-form {
    max-width: 100%;
}

.translations-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 32px;
}

.translation-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    transition: all 0.2s ease;
}

.translation-item:hover {
    border-color: var(--primary-red);
    box-shadow: 0 2px 8px rgba(193, 56, 50, 0.1);
}

.translation-item-group {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
}

.translation-item-group:hover {
    border-color: var(--primary-red);
    box-shadow: 0 2px 8px rgba(193, 56, 50, 0.1);
}

.translation-key-header {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-red);
    margin-bottom: 16px;
    font-family: 'Courier New', monospace;
    background-color: var(--bg-light);
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 4px solid var(--primary-red);
}

.translation-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.translation-lang-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.translation-lang-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-gray);
    display: flex;
    align-items: center;
    gap: 6px;
}

.translation-key {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-gray);
    margin-bottom: 8px;
    font-family: 'Courier New', monospace;
    background-color: var(--bg-light);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.translation-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
    resize: vertical;
    min-height: 44px;
}

.translation-input:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(193, 56, 50, 0.1);
}

/* Arabic text direction */
.translation-input[data-lang="ar"] {
    direction: rtl;
    text-align: right;
    font-family: 'Arial', sans-serif;
}

.translation-input.textarea {
    min-height: 80px;
}

.translations-search {
    margin-bottom: 24px;
    position: relative;
}

.translations-search input {
    width: 100%;
    padding: 12px 40px 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
}

.translations-search svg {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-gray);
}

.translation-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-cream);
    border-radius: 8px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-item svg {
    color: var(--primary-green);
}

.stat-item span {
    font-size: 14px;
    color: var(--text-gray);
}

.stat-item strong {
    color: var(--text-dark);
    font-weight: 600;
}

/* Permissions Grid */
.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    padding: 16px;
    background-color: var(--bg-light);
    border-radius: 8px;
}

.permission-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.permission-item:hover {
    background-color: white;
}

.permission-item input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.permission-item span {
    font-size: 14px;
    color: var(--text-dark);
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-dark);
}

.page-header p {
    font-size: 14px;
    color: var(--text-gray);
    margin-top: 4px;
}

/* ===== PHASE PROGRESS BAR ===== */
.phase-progress-container {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
}

.phase-progress-container h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 20px;
}

.phase-progress-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.phase-progress-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.phase-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.phase-name {
    color: var(--text-dark);
    font-weight: 500;
}

.phase-count {
    background: var(--bg-light);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 12px;
}

.phase-progress-bar {
    height: 8px;
    background: var(--bg-light);
    border-radius: 4px;
    overflow: hidden;
}

.phase-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.phase-registro {
    background: linear-gradient(90deg, #3B82F6, #60A5FA);
}

.phase-escaneo {
    background: linear-gradient(90deg, #8B5CF6, #A78BFA);
}

.phase-clasificacion {
    background: linear-gradient(90deg, #EC4899, #F472B6);
}

.phase-revision {
    background: linear-gradient(90deg, #F59E0B, #FBBF24);
}

.phase-tramitacion {
    background: linear-gradient(90deg, #F97316, #FB923C);
}

.phase-requerimientos {
    background: linear-gradient(90deg, #EF4444, #F87171);
}

.phase-completado {
    background: linear-gradient(90deg, #10B981, #34D399);
}

@media (max-width: 768px) {
    .phase-progress-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .phase-progress-grid {
        grid-template-columns: 1fr;
    }
}
