:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(22, 28, 45, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --input-bg: rgba(15, 23, 42, 0.8);
    --drawer-bg: #0e1322;
    
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    
    --success: #10b981;
    --warning: #f59e0b;
    --info: #3b82f6;
    --danger: #ef4444;
    --neutral: #6b7280;

    --font-family: 'Outfit', sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-theme {
    --bg-color: #f3f4f6;
    --card-bg: rgba(255, 255, 255, 0.95);
    --border-color: rgba(0, 0, 0, 0.08);
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --input-bg: rgba(255, 255, 255, 0.9);
    --drawer-bg: #ffffff;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    background-color: rgba(11, 15, 25, 0.8);
    position: sticky;
    top: 0;
    z-index: 10;
}

.btn-theme-toggle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1.2rem;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.btn-theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    background-color: rgba(11, 15, 25, 0.8);
    position: sticky;
    top: 0;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-img {
    height: 38px;
    width: auto;
    object-fit: contain;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.logo h1 span {
    color: var(--primary-color);
}

.system-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(16, 185, 129, 0.1);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    font-size: 0.85rem;
    font-weight: 500;
}

.status-indicator {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success);
}

/* Layout container */
.app-container {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* KPI Dashboard */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(16px);
    padding: 1.5rem;
    border-radius: 16px;
    transition: var(--transition);
    cursor: pointer;
}

.kpi-card:hover {
    transform: translateY(-4px);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 10px 20px -10px rgba(99, 102, 241, 0.2);
}

.kpi-card h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.kpi-value {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* Cards & Layout */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(16px);
    border-radius: 16px;
    padding: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.card-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
}

/* Buttons */
.btn {
    font-family: var(--font-family);
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background-color: var(--danger);
    color: #fff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* Filters */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.filter-bar input, .filter-bar select {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.6rem 1rem;
    border-radius: 10px;
    outline: none;
    font-family: var(--font-family);
    font-size: 0.9rem;
    transition: var(--transition);
}

.filter-bar input:focus, .filter-bar select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.filter-bar input {
    flex: 1;
    min-width: 200px;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

th {
    background-color: rgba(15, 23, 42, 0.6);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

tbody tr {
    cursor: pointer;
    transition: var(--transition);
}

tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.loading-state, .empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-vaca { background: rgba(99, 102, 241, 0.15); color: var(--primary-color); }
.badge-crianza { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.badge-tambo { background: rgba(16, 185, 129, 0.15); color: var(--success); }

.badge-activo { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-preñado { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-seco { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.badge-vacio { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-default { background: rgba(107, 114, 128, 0.15); color: var(--neutral); }

/* Drawer Side Panel */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    z-index: 99;
}

.drawer-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.drawer {
    position: fixed;
    top: 0;
    right: -450px;
    width: 450px;
    max-width: 100%;
    height: 100%;
    background-color: var(--drawer-bg);
    border-left: 1px solid var(--border-color);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    z-index: 100;
    transition: var(--transition);
    padding: 2.5rem 2rem;
    overflow-y: auto;
}

.drawer.active {
    right: 0;
}

.btn-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-close:hover {
    color: var(--text-primary);
}

/* Forms */
.app-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1.5rem;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input, .form-group select, .form-group textarea {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-family: var(--font-family);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

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

/* Profile Detail Layout */
.profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.profile-avatar {
    font-size: 2.5rem;
    background: rgba(255, 255, 255, 0.05);
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.profile-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-item.full-width {
    grid-column: span 2;
}

.detail-item .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.detail-item .value {
    font-size: 1rem;
    font-weight: 500;
}

.detail-item .text-block {
    background: rgba(255, 255, 255, 0.02);
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    min-height: 80px;
}

/* Events Section & Timeline */
.events-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.events-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.events-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 8px;
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 350px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.timeline-empty {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 1.5rem 0;
}

.timeline-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    position: relative;
    border-left: 4px solid var(--primary-color);
}

.timeline-item.ev-paricion { border-left-color: var(--success); }
.timeline-item.ev-preñez { border-left-color: var(--warning); }
.timeline-item.ev-enfermedad { border-left-color: var(--danger); }
.timeline-item.ev-secado { border-left-color: var(--info); }
.timeline-item.ev-muerte, .timeline-item.ev-venta { border-left-color: var(--neutral); }

.timeline-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.timeline-type {
    font-weight: 700;
    text-transform: uppercase;
}

.timeline-desc {
    font-size: 0.9rem;
    line-height: 1.4;
}

.conditional-fields {
    background: rgba(255, 255, 255, 0.01);
    border: 1px dashed var(--border-color);
    padding: 1rem;
    border-radius: 10px;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Tabs Navigation Styles */
.app-tabs {
    display: flex;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 1rem;
    position: relative;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -0.6rem;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 2px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Reproducción Section */
.repro-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.repro-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.repro-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.repro-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.repro-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.repro-item-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.repro-item-title {
    font-weight: 700;
    text-transform: uppercase;
}

.repro-item-desc {
    font-size: 0.9rem;
}

/* Login Screen */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
                      radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.08) 0%, transparent 40%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(8px);
    transition: var(--transition);
}

.login-box {
    width: 90%;
    max-width: 400px;
    padding: 2.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.login-screen.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.98);
}
