:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;
    --accent: #8b5cf6;
    --background: #0f172a;
    --surface: rgba(255, 255, 255, 0.1);
    --surface-hover: rgba(255, 255, 255, 0.15);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --card-radius: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--background);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.background-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background:
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(236, 72, 153, 0.15), transparent 25%);
    filter: blur(40px);
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

.logo-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.app-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Search */
.search-section {
    position: sticky;
    top: 2rem;
    z-index: 100;
    margin-bottom: 2rem;
    animation: fadeInUp 0.8s ease-out 0.2s backwards;
}

.search-container {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.4rem;
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 1rem 1rem 1rem 3.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    outline: none;
    transition: all 0.3s ease;
}

.search-box input:focus {
    background: var(--surface-hover);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.filters {
    display: flex;
    gap: 0.8rem;
    overflow-x: auto;
    padding-bottom: 0.2rem;
}

.filter-chip {
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.filter-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Student Grid */
.student-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    animation: fadeInUp 0.8s ease-out 0.4s backwards;
    padding-bottom: 4rem;
}

.student-card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.student-card:hover {
    transform: translateY(-4px);
    background: var(--surface-hover);
    border-color: rgba(99, 102, 241, 0.3);
}

.card-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 1rem;
}

.student-photo-container {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.student-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.student-card:hover .student-photo:not(.is-placeholder) {
    transform: scale(1.1);
}

.student-photo.is-placeholder {
    opacity: 0.3;
    padding: 10px;
    filter: grayscale(100%);
}

.student-info-header {
    flex: 1;
}

.student-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
}

.dni-tiny {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    background: rgba(0, 0, 0, 0.2);
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
}

.group-badge {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.tutor-box {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.8rem;
    border-radius: 8px;
}

.tutor-label {
    text-transform: uppercase;
    font-size: 0.65rem;
    color: #64748b;
    margin-bottom: 0.2rem;
    letter-spacing: 0.05em;
}

.tutor-name {
    font-size: 0.95rem;
    color: #e2e8f0;
    font-weight: 500;
}

.tutor-dni {
    font-size: 0.8rem;
    color: #94a3b8;
    font-family: monospace;
}

.card-actions {
    margin-top: auto;
}

.btn-exit {
    width: 100%;
    padding: 0.8rem;
    background: rgba(236, 72, 153, 0.1);
    /* Pinkish */
    border: 1px solid rgba(236, 72, 153, 0.3);
    color: #f472b6;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.btn-exit:hover {
    background: rgba(236, 72, 153, 0.2);
    color: #fbcfe8;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    background: #1e293b;
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: translateY(0);
    transition: transform 0.3s ease;
}

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

.modal-header h3 {
    font-size: 1.5rem;
    color: white;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.student-target {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-select {
    width: 100%;
    padding: 0.8rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    outline: none;
}

.radio-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.radio-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.radio-card:has(input:checked) {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    color: white;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.btn-primary,
.btn-secondary {
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
}

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

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

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
}

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

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hidden {
    display: none !important;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s infinite linear;
    margin: 0 auto 1rem;
}

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

/* Add this to style.css */

.phones-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.phone-chip {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 8px;
    padding: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.phone-chip:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: translateY(-2px);
    border-color: rgba(99, 102, 241, 0.5);
}

.phone-chip i {
    font-size: 1.2rem;
    color: var(--primary);
}

.phone-data {
    display: flex;
    flex-direction: column;
}

.phone-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.phone-number {
    font-size: 0.95rem;
    color: white;
    font-weight: 500;
}

/* Urgent Phone Style */
.phone-chip.urgent {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.phone-chip.urgent i {
    color: #ef4444;
}

.phone-chip.urgent:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.6);
}

.no-phones {
    grid-column: span 2;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 0.5rem;
    font-style: italic;
}

/* PRINT STYLES */
.ticket-hidden {
    display: none;
}

@media print {

    /* Hide everything */
    body * {
        visibility: hidden;
    }

    .app-container,
    .background-mesh,
    .modal-overlay {
        display: none !important;
    }

    /* Show only ticket */
    #printableTicket,
    #printableTicket * {
        visibility: visible;
        display: block;
    }

    #printableTicket {
        position: absolute;
        left: 0;
        top: 0;
        width: 80mm;
        /* Standard thermal width */
        padding: 5px;
        font-family: 'Courier New', Courier, monospace;
        /* Typical receipt font */
        color: black;
        background: white;
    }

    .ticket-header {
        text-align: center;
        margin-bottom: 20px;
    }

    .ticket-logo {
        max-width: 150px;
        filter: grayscale(100%);
        margin-bottom: 5px;
    }

    .ticket-header h3 {
        font-size: 1.2rem;
        margin: 5px 0;
        border-bottom: 2px solid black;
        display: inline-block;
        padding-bottom: 2px;
    }

    .ticket-body {
        font-size: 0.9rem;
        line-height: 1.4;
    }

    .ticket-row {
        margin-bottom: 8px;
    }

    .ticket-divider {
        border-top: 1px dashed black;
        margin: 10px 0;
    }

    .ticket-signature {
        margin-top: 30px;
        text-align: center;
    }

    .ticket-footer {
        margin-top: 20px;
        font-size: 0.7rem;
        text-align: center;
    }
}

/* History & Stats Styles */

.special-chip {
    background: rgba(168, 85, 247, 0.15) !important;
    border-color: rgba(168, 85, 247, 0.4) !important;
    color: #d8b4fe !important;
    font-weight: 600;
}

.special-chip i {
    margin-right: 0.5rem;
}

.special-chip:hover {
    background: rgba(168, 85, 247, 0.25) !important;
}

.exit-counter-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 10;
    transition: all 0.3s ease;
}

.exit-counter-badge.has-exits {
    background: rgba(236, 72, 153, 0.2);
    border-color: rgba(236, 72, 153, 0.4);
    color: #f472b6;
}

.student-card {
    position: relative;
}

.recurrence-alert {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 0.5rem;
    margin: 0 1rem 1rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
    0% {
        background: rgba(239, 68, 68, 0.15);
    }

    50% {
        background: rgba(239, 68, 68, 0.3);
    }

    100% {
        background: rgba(239, 68, 68, 0.15);
    }
}

.modal-large {
    max-width: 900px !important;
    width: 95%;
}

.history-body {
    max-height: 70vh;
    overflow-y: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    color: #e2e8f0;
    font-size: 0.9rem;
}

.history-table th {
    text-align: left;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    position: sticky;
    top: 0;
    background: #1e293b;
}

.history-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.history-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.group-badge.small {
    font-size: 0.75rem;
    padding: 2px 6px;
}

.btn-icon-small {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.2rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.delete-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.hist-stat-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    min-width: 100px;
    flex: 1;
    transition: all 0.3s ease;
}

.hist-stat-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
}

.hist-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
}

.hist-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
}

/* Periods Grid */
.periods-grid {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: white;
    cursor: pointer;
}


.svg-chart-container {
    height: 120px;
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.chart-bar {
    flex: 1;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    min-height: 2px;
}

.chart-bar:hover {
    background: #818cf8;
    filter: brightness(1.2);
}

.chart-bar::after {
    content: attr(data-value);
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
}

.chart-bar:hover::after {
    opacity: 1;
}

.chart-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 4px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

    .app-header h1 {
        font-size: 1.8rem;
    }

    .search-container {
        flex-direction: column;
    }

    .filters {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    .student-grid {
        grid-template-columns: 1fr;
        /* Single column on mobile */
    }

    .modal {
        width: 95%;
        padding: 1.5rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-large {
        width: 100%;
        height: 100%;
        border-radius: 0;
        max-height: none;
    }

    .radio-group {
        grid-template-columns: 1fr;
        /* Stack radio cards */
    }

    .phones-section {
        grid-template-columns: 1fr;
        /* Stack phones */
    }

    .modal-footer {
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        text-align: center;
    }

    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .action-buttons button {
        width: 100%;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    color: white;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    max-width: 450px;
    pointer-events: auto;
    animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.3s ease;
}

.toast.removing {
    opacity: 0;
    transform: translateX(100%);
}

.toast-icon {
    font-size: 1.5rem;
}

.toast-success {
    border-left: 4px solid #10b981;
}

.toast-success .toast-icon {
    color: #10b981;
}

.toast-error {
    border-left: 4px solid #ef4444;
}

.toast-error .toast-icon {
    color: #ef4444;
}

.toast-warning {
    border-left: 4px solid #f59e0b;
}

.toast-warning .toast-icon {
    color: #f59e0b;
}

.toast-message {
    font-weight: 500;
    font-size: 0.95rem;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(100%) translateY(0);
    }

    to {
        opacity: 1;
        transform: translateX(0) translateY(0);
    }
}