/* Amalgama - Gestión Docente - Estilos */
:root {
    --bg-primary: #f5f6fa;
    --bg-sidebar: #2c3e50;
    --bg-card: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-sidebar: #ecf0f1;
    --accent: #3498db;
    --accent-hover: #2980b9;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #16a085;
    --border: #dcdde1;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
    --radius: 8px;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

#app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
#sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s;
}

.logo {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.logo h2 {
    font-size: 1.3em;
    font-weight: 600;
}

.logo small {
    color: rgba(255,255,255,0.6);
    font-size: 0.8em;
}

#nav-menu {
    list-style: none;
    padding: 10px 0;
}

#nav-menu li a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.95em;
}

#nav-menu li a:hover,
#nav-menu li a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left: 3px solid var(--accent);
}

.icon {
    margin-right: 10px;
    font-size: 1.2em;
    width: 24px;
    text-align: center;
}

/* Main content */
main {
    flex: 1;
    margin-left: 260px;
    padding: 0;
    min-height: 100vh;
}

#topbar {
    background: var(--bg-card);
    padding: 15px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

#topbar h1 {
    font-size: 1.4em;
    font-weight: 600;
}

#menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    margin-right: 15px;
}

#page-content {
    padding: 25px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

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

.card-header h3 {
    font-size: 1.1em;
    font-weight: 600;
}

/* Grid */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-5 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); }
    main { margin-left: 0; }
    #menu-toggle { display: block; }
    .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
}

/* Stat cards */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
}

.stat-info h4 {
    font-size: 1.8em;
    font-weight: 700;
    line-height: 1;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 0.85em;
    margin-top: 5px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

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

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

th {
    background: var(--bg-primary);
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

tr:hover {
    background: rgba(52,152,219,0.05);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--border); color: var(--text-primary); }
.btn-secondary:hover { background: #c0c0c0; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.8em; }

/* Forms */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95em;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-row {
    display: flex;
    gap: 15px;
}

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

/* 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: 200;
}

#modal-overlay.hidden {
    display: none;
}

#modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

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

#modal-header h3 {
    font-size: 1.2em;
}

#modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

#modal-body {
    padding: 20px;
}

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

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: #d5f5e3; color: #1e8449; }
.badge-warning { background: #fdebd0; color: #d68910; }
.badge-danger { background: #fadbd8; color: #c0392b; }
.badge-info { background: #d4efdf; color: #1e8449; }
.badge-primary { background: #d6eaf8; color: #2471a3; }

/* Search */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-bar input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1em;
}

/* Schedule grid */
.schedule-grid {
    display: grid;
    grid-template-columns: 80px repeat(5, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.schedule-header {
    background: var(--bg-sidebar);
    color: #fff;
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 0.85em;
}

.schedule-time {
    background: var(--bg-primary);
    padding: 10px 8px;
    font-size: 0.8em;
    text-align: center;
    font-weight: 500;
}

.schedule-cell {
    background: var(--bg-card);
    min-height: 60px;
    padding: 4px;
    position: relative;
}

.schedule-event {
    background: var(--accent);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    margin-bottom: 2px;
    cursor: pointer;
    overflow: hidden;
}

.schedule-event:hover {
    opacity: 0.9;
}

/* Grade colors */
.grade-excellent { color: #27ae60; font-weight: 600; }
.grade-good { color: #2ecc71; }
.grade-pass { color: #f39c12; }
.grade-fail { color: #e74c3c; font-weight: 600; }

/* Toast */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
}

.toast {
    background: var(--bg-card);
    border-left: 4px solid var(--accent);
    padding: 15px 20px;
    border-radius: var(--radius);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin-bottom: 10px;
    animation: slideIn 0.3s ease;
    max-width: 350px;
}

.toast-success { border-left-color: var(--success); }
.toast-danger { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }

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

/* Attendance grid */
.attendance-grid {
    display: grid;
    gap: 4px;
}

.attendance-row {
    display: grid;
    grid-template-columns: 200px repeat(auto-fill, minmax(100px, 1fr));
    gap: 4px;
    align-items: center;
}

.attendance-student {
    font-weight: 500;
    padding: 8px;
}

.attendance-cell {
    text-align: center;
    padding: 8px;
}

.attendance-status {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    cursor: pointer;
    margin: 2px;
}

.status-present { background: #d5f5e3; color: #1e8449; }
.status-absent { background: #fadbd8; color: #c0392b; }
.status-late { background: #fdebd0; color: #d68910; }
.status-justified { background: #d6eaf8; color: #2471a3; }
.status-early { background: #e8daef; color: #7d3c98; }

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

.tab {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    font-weight: 500;
}

.tab:hover {
    color: var(--accent);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Select2-like custom select */
.select-wrapper {
    position: relative;
}

.select-wrapper select {
    appearance: none;
    padding-right: 30px;
}

/* Course card */
.course-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid var(--accent);
}

.course-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.12);
}

.course-card h4 {
    margin-bottom: 5px;
}

.course-card p {
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Student card */
.student-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: var(--shadow);
    margin-bottom: 10px;
}

.student-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    font-weight: 600;
}

.student-info h4 {
    margin-bottom: 2px;
}

.student-info p {
    font-size: 0.85em;
    color: var(--text-secondary);
}

.student-stats {
    margin-left: auto;
    display: flex;
    gap: 15px;
}

/* Grade input */
.grade-input {
    width: 60px;
    padding: 6px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.grade-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Print styles */
@media print {
    #sidebar, #topbar, .btn { display: none !important; }
    main { margin-left: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.empty-state .icon {
    font-size: 3em;
    margin-bottom: 15px;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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