/* =============================================
   PRACTIEMPRESA ERP - Estilos Corporativos
   Tipografía: Titillium Web
   Colores: #326400, #669900, #A4BC15
============================================= */

@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@300;400;600;700&display=swap');

/* Variables CSS */
:root {
    --primary-dark: #326400;
    --primary-medium: #669900;
    --primary-light: #A4BC15;
    --text-dark: #212327;
    --text-medium: #555;
    --text-light: #888;
    --background: #f5f7fa;
    --white: #ffffff;
    --border-color: #e1e5eb;
    --error: #dc3545;
    --success: #28a745;
    --warning: #ffc107;
    --info: #17a2b8;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 20px;

    --sidebar-width: 260px;
    --header-height: 60px;
}

/* Reset y Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Titillium Web', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--background);
}

a {
    color: var(--primary-medium);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
}

/* Tipografía */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

/* =============================================
   COMPONENTES - Botones
============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-medium);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--white);
    color: var(--text-dark);
    border: 1px solid var(--border-color);
}

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

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* =============================================
   COMPONENTES - Formularios
============================================= */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-medium);
    box-shadow: 0 0 0 3px rgba(102, 153, 0, 0.15);
}

.form-control.error {
    border-color: var(--error);
}

.form-text {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}

.form-error {
    color: var(--error);
    font-size: 12px;
    margin-top: 4px;
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* =============================================
   COMPONENTES - Cards
============================================= */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

.card-header h3 {
    margin: 0;
}

.card-body {
    padding: 20px;
}

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

/* =============================================
   COMPONENTES - Tablas
============================================= */
.table {
    width: 100%;
    border-collapse: collapse;
}

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

.table th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-medium);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background: rgba(102, 153, 0, 0.05);
}

/* =============================================
   COMPONENTES - Badges
============================================= */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-primary { background: rgba(102, 153, 0, 0.15); color: var(--primary-dark); }
.badge-secondary { background: #e9ecef; color: #495057; }

/* =============================================
   COMPONENTES - Alertas
============================================= */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* =============================================
   COMPONENTES - Modal
============================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

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

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-md {
    max-width: 600px;
}

.modal-lg {
    max-width: 700px;
}

.modal-xl {
    max-width: 850px;
}

.modal-row {
    display: flex;
    gap: 1rem;
}

.modal-row > .form-group {
    flex: 1;
}

.modal-grid-dims {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

/* Filter bar - flex container that wraps on mobile */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Form row - side-by-side fields that stack on mobile */
.form-row {
    display: flex;
    gap: 1rem;
}

.form-row > .form-group {
    flex: 1;
}

/* Table wrapper for horizontal scroll on mobile */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Hamburger menu button */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-dark);
}

.hamburger-btn svg {
    width: 24px;
    height: 24px;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* =============================================
   LAYOUT - Login
============================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-medium) 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo img {
    height: 80px;
}

.login-title {
    text-align: center;
    margin-bottom: 30px;
}

.login-title h1 {
    font-size: 1.5rem;
    color: var(--primary-dark);
    margin-bottom: 8px;
}

.login-title p {
    color: var(--text-light);
}

/* =============================================
   LAYOUT - Dashboard
============================================= */
.app-layout {
    display: flex;
    min-height: 100vh;
}

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

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo img {
    height: 40px;
}

.sidebar-logo span {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
}

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

.nav-section {
    margin-bottom: 20px;
}

.nav-section-title {
    padding: 8px 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-medium);
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(102, 153, 0, 0.08);
    color: var(--primary-dark);
}

.nav-item.active {
    background: rgba(102, 153, 0, 0.1);
    color: var(--primary-dark);
    border-left-color: var(--primary-medium);
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

/* Sub-menús colapsables */
.nav-parent {
    position: relative;
}

.nav-parent-toggle {
    justify-content: flex-start;
}

.nav-item-label {
    flex: 1;
}

.nav-chevron {
    width: 16px !important;
    height: 16px !important;
    transition: transform 0.2s;
    margin-left: auto;
}

.nav-parent.open > .nav-parent-toggle .nav-chevron {
    transform: rotate(180deg);
}

.nav-children {
    display: none;
}

.nav-parent.open > .nav-children {
    display: block;
}

.nav-child {
    padding: 8px 20px 8px 36px !important;
    font-size: 13px;
    gap: 8px !important;
    border-left: 3px solid transparent;
}

.nav-child-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-light);
    flex-shrink: 0;
}

.nav-child.active .nav-child-dot,
.nav-child:hover .nav-child-dot {
    background: var(--primary-medium);
}

/* Tabs scrollable para muchos tabs */
.tabs-container {
    flex-wrap: wrap;
}

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

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

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

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 12px;
    color: var(--text-light);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.main-header {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-title h2 {
    font-size: 1.25rem;
    margin: 0;
}

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

.main-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* =============================================
   COMPONENTES - Stats Cards
============================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

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

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

.stat-icon.green { background: rgba(102, 153, 0, 0.15); color: var(--primary-dark); }
.stat-icon.blue { background: rgba(23, 162, 184, 0.15); color: var(--info); }
.stat-icon.yellow { background: rgba(255, 193, 7, 0.15); color: #856404; }
.stat-icon.red { background: rgba(220, 53, 69, 0.15); color: var(--error); }

.stat-icon svg {
    width: 28px;
    height: 28px;
}

.stat-content h4 {
    font-size: 12px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

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

/* =============================================
   COMPONENTES - Progress
============================================= */
.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-medium);
    border-radius: 4px;
    transition: width 0.3s;
}

.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger { background: var(--error); }

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

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-medium);
    margin-bottom: 8px;
}

/* =============================================
   COMPONENTES - Tabs
============================================= */
.tabs-container {
    display: flex;
    gap: 0;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 4px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 12px 24px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-medium);
}

.tab-btn:hover {
    background: rgba(102, 153, 0, 0.08);
    color: var(--primary-dark);
}

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

/* =============================================
   COMPONENTES - Goal Card
============================================= */
.goal-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.goal-card:hover {
    box-shadow: var(--shadow-md);
}

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

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

.goal-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-light);
}

.goal-progress {
    margin-top: 16px;
}

.goal-progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 13px;
}

/* =============================================
   RESPONSIVE
============================================= */

/* --- Tablet and below (1024px) --- */
@media (max-width: 1024px) {
    .hamburger-btn {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .sidebar.open {
        transform: translateX(0);
    }

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

/* --- Tablet portrait (768px) --- */
@media (max-width: 768px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.1rem; }

    .main-header {
        padding: 0 16px;
        height: auto;
        min-height: var(--header-height);
    }

    .header-actions {
        gap: 8px;
        flex-wrap: wrap;
    }

    .main-body {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
        gap: 12px;
    }

    .stat-icon {
        width: 44px;
        height: 44px;
    }

    .stat-icon svg {
        width: 22px;
        height: 22px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .card-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .card-body {
        padding: 16px;
    }

    .table th,
    .table td {
        padding: 10px 12px;
        font-size: 13px;
    }

    .tabs-container {
        flex-wrap: wrap;
    }

    .tab-btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .login-card {
        padding: 30px 20px;
    }

    .modal {
        width: 95%;
        max-height: 85vh;
    }

    .modal-md,
    .modal-lg,
    .modal-xl {
        max-width: 95%;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
    }

    .modal-grid-dims {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .filter-bar .form-control {
        max-width: none !important;
        width: 100%;
    }

    .empty-state {
        padding: 40px 16px;
    }

    .empty-state svg {
        width: 60px;
        height: 60px;
    }
}

/* --- Mobile (480px) --- */
@media (max-width: 480px) {
    h1 { font-size: 1.3rem; }
    h2 { font-size: 1.15rem; }

    .main-header {
        padding: 0 12px;
    }

    .main-body {
        padding: 12px;
    }

    .btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    .btn-sm {
        padding: 5px 10px;
        font-size: 12px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-card {
        padding: 12px;
        gap: 10px;
    }

    .stat-icon {
        width: 38px;
        height: 38px;
    }

    .stat-icon svg {
        width: 18px;
        height: 18px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .card-header {
        padding: 12px;
    }

    .card-body {
        padding: 12px;
    }

    .table th,
    .table td {
        padding: 8px;
        font-size: 12px;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal {
        width: 100%;
        max-height: 90vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .modal-md,
    .modal-lg,
    .modal-xl {
        max-width: 100%;
    }

    .modal-row {
        flex-direction: column;
        gap: 0;
    }

    .modal-grid-dims {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .goal-card {
        padding: 14px;
    }

    .goal-header {
        flex-direction: column;
        gap: 8px;
    }

    .goal-meta {
        flex-wrap: wrap;
        gap: 6px;
    }
}

/* =============================================
   UTILITIES
============================================= */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-light); }
.text-success { color: var(--success); }
.text-danger { color: var(--error); }
.text-primary { color: var(--primary-medium); }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

.hidden { display: none !important; }

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-medium);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay .spinner {
    width: 40px;
    height: 40px;
    border-width: 3px;
}
