/* ==========================================
   RYUZENK MITIGATION - CLIENTS STYLES
   ========================================== */

/* RESET */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* VARIABLES CSS */
:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
}

/* BODY */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
}

/* ==========================================
   LAYOUT
   ========================================== */

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ==========================================
   SIDEBAR
   ========================================== */

.sidebar {
    width: 260px;
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 30px;
    padding: 10px;
}

.nav-menu {
    list-style: none;
}

.nav-item {
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--gray-700);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-link:hover {
    background: var(--gray-100);
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

.nav-link-icon {
    margin-right: 12px;
    font-size: 20px;
}

/* ==========================================
   MAIN CONTENT
   ========================================== */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==========================================
   HEADER
   ========================================== */

.header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title {
    font-size: 24px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

#connection-status {
    margin-right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--success);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    display: inline-block;
}

/* ==========================================
   BUTTONS
   ========================================== */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-small {
    padding: 4px 8px;
    font-size: 12px;
}

/* ==========================================
   FILTER BAR (NUEVO)
   ========================================== */

.filter-bar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.filter-section {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-label {
    color: white;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

.filter-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.filter-pill {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
    user-select: none;
}

.filter-pill:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.filter-pill.active {
    background: white;
    color: #667eea;
    border-color: white;
    font-weight: 700;
}

.btn-clear-filters {
    padding: 8px 16px;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    border-radius: 20px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.btn-clear-filters:hover {
    background: rgba(239, 68, 68, 1);
    transform: scale(1.05);
}

.search-input-large {
    padding: 12px 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    width: 100%;
    max-width: 500px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.95);
    transition: all 0.2s;
}

.search-input-large:focus {
    outline: none;
    border-color: white;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ==========================================
   VIEW CONTROLS
   ========================================== */

.view-controls {
    padding: 16px 24px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.view-tabs {
    display: flex;
    gap: 8px;
}

.view-tab {
    padding: 10px 20px;
    background: transparent;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.view-tab:hover {
    background: var(--gray-50);
    border-color: var(--primary);
}

.view-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.view-info {
    color: var(--gray-600);
    font-size: 14px;
    font-weight: 500;
}

/* ==========================================
   STATS BAR
   ========================================== */

.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px 24px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--gray-50);
    border-radius: 12px;
}

.stat-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 4px;
    font-weight: 500;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
}

/* ==========================================
   CONTENT AREA
   ========================================== */

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ==========================================
   CARDS
   ========================================== */

.card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ==========================================
   CLIENT GRID (Vista Tabla)
   ========================================== */

.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.client-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.2s;
    cursor: pointer;
    border: 2px solid transparent;
}

.client-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
    border-color: var(--primary);
}

.client-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 16px;
}

.client-info h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.client-case-number {
    font-size: 13px;
    color: var(--gray-600);
    font-family: monospace;
}

.client-actions {
    display: flex;
    gap: 8px;
}

.client-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.client-meta-item {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: var(--gray-700);
}

.client-meta-item span:first-child {
    width: 24px;
}

.client-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.client-amount {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.client-days {
    font-size: 13px;
    color: var(--gray-600);
}

/* ==========================================
   TABLES
   ========================================== */

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--gray-50);
}

th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 16px;
    border-top: 1px solid var(--gray-200);
    font-size: 14px;
}

tbody tr {
    transition: background 0.2s;
}

tbody tr:hover {
    background: var(--gray-50);
}

/* ==========================================
   BADGES
   ========================================== */

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: var(--gray-200); color: var(--gray-700); }

/* ==========================================
   PRIORITY COLORS
   ========================================== */

.priority-baja { color: var(--gray-600); }
.priority-media { color: var(--warning); }
.priority-alta { color: var(--danger); }
.priority-urgente { color: var(--danger); font-weight: 700; }

/* ==========================================
   KANBAN BOARD
   ========================================== */

.kanban-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.kanban-column {
    background: var(--gray-100);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 400px);
}

.kanban-header {
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kanban-count {
    background: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.kanban-cards {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kanban-card {
    background: white;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.2s;
}

.kanban-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.kanban-card-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.kanban-card-meta {
    font-size: 12px;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
}

/* ==========================================
   MODAL
   ========================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 1000px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--gray-200);
    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;
    cursor: pointer;
    color: var(--gray-600);
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

.modal-close:hover {
    color: var(--gray-900);
}

.modal-body {
    padding: 0;
}

/* ==========================================
   PROFILE MODAL STYLES (CV-STYLE)
   ========================================== */

.profile-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 0;
    min-height: 500px;
}

/* SIDEBAR PROFILE */
.profile-sidebar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px 30px;
    color: white;
    display: flex;
    flex-direction: column;
}

.profile-avatar {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.avatar-circle {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 4px solid rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: 700;
    color: white;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.profile-name {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    color: white;
}

.profile-subtitle {
    text-align: center;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    font-family: monospace;
    margin-bottom: 8px;
}

.profile-info-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 2px solid rgba(255, 255, 255, 0.2);
}

.profile-info-section h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-contact {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 2px solid rgba(255, 255, 255, 0.2);
}

.profile-contact h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.95);
}

.contact-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

/* MAIN PROFILE CONTENT */
.profile-main {
    padding: 40px;
    background: white;
}

.info-section {
    margin-bottom: 32px;
}

.info-section h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 3px solid var(--primary);
    display: inline-block;
}

.info-row {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    gap: 12px;
    flex: 1;
    min-width: 200px;
}

.info-bullet {
    font-size: 16px;
    color: var(--primary);
    flex-shrink: 0;
}

.info-item strong {
    display: block;
    font-size: 12px;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.info-item p {
    font-size: 14px;
    color: var(--gray-900);
    margin: 0;
    font-weight: 500;
}

/* FINANCIAL GRID */
.financial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.financial-card {
    background: var(--gray-50);
    padding: 20px;
    border-radius: 10px;
    border: 2px solid var(--gray-200);
    transition: all 0.2s;
}

.financial-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.financial-label {
    display: block;
    font-size: 11px;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    font-weight: 600;
}

.financial-amount {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
}

.financial-status {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    text-transform: uppercase;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .profile-container {
        grid-template-columns: 1fr;
    }
    
    .profile-sidebar {
        border-radius: 12px 12px 0 0;
    }
    
    .profile-main {
        border-radius: 0 0 12px 12px;
        padding: 24px;
    }
    
    .info-row {
        flex-direction: column;
    }
    
    .financial-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   LOADING
   ========================================== */

.loading {
    text-align: center;
    padding: 60px;
    color: var(--gray-600);
}

.spinner {
    border: 3px solid var(--gray-200);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================
   MESSAGES
   ========================================== */

.error-message {
    background: #fee2e2;
    color: #991b1b;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.success-message {
    background: #d1fae5;
    color: #065f46;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-600);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 14px;
}