@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

* { box-sizing: border-box; }
body { 
    margin: 0; 
    font-family: 'Nunito', system-ui, sans-serif; 
    background: #ffffff; 
    color: #3c3c3c; 
    padding-bottom: 40px;
}

/* Playful Typography */
h1, h2, h3 { font-weight: 800; color: #4b4b4b; margin-top: 0; }
.muted { color: #afafaf; font-weight: 600; }

/* Hero Section */
.hero { 
    background: #1cb0f6; /* Duolingo Blue */
    color: white; 
    padding: 30px max(18px, 7vw); 
    display: flex; 
    justify-content: space-between; 
    gap: 22px; 
    align-items: center; 
    flex-wrap: wrap; 
    border-bottom: 4px solid #1899d6;
}
.hero h1 { color: white; font-size: clamp(32px, 5vw, 48px); line-height: 1.1; margin: 12px 0; letter-spacing: -0.5px; }
.hero p { color: #ddf4ff; font-size: 1.1rem; font-weight: 600; max-width: 700px; }
.pill { 
    display: inline-flex; gap: 8px; align-items: center; padding: 8px 16px; 
    background: rgba(255,255,255,0.2); border: 2px solid rgba(255,255,255,0.4); 
    border-radius: 999px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; font-size: 0.85rem;
}

/* Layout */
.wrap { width: min(1180px, 94vw); margin: 30px auto; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }

/* Duolingo style Cards */
.card { 
    background: white; 
    border: 2px solid #e5e5e5; 
    border-radius: 24px; 
    padding: 28px; 
    margin-bottom: 24px; 
    box-shadow: 0 4px 0 #e5e5e5;
}
.public-note { background: #ffdf00; border: 2px solid #e5c800; border-radius: 20px; padding: 20px; box-shadow: 0 4px 0 #e5c800; color: #b28a00; }
.public-note b { color: #8a6a00; font-size: 1.1rem; }
.public-note p { color: #9a7a00; margin-bottom: 0; }

/* Buttons */
.btn { 
    border: none; 
    background: #58cc02; /* Green */
    color: white; 
    font-weight: 800; 
    font-family: inherit;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 16px; 
    padding: 14px 24px; 
    text-decoration: none; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px; 
    cursor: pointer; 
    border-bottom: 4px solid #58a700;
    transition: all 0.1s ease;
}
.btn:active { transform: translateY(4px); border-bottom-width: 0; margin-top: 4px; padding-bottom: 14px; }
.btn.secondary { background: #ffffff; color: #1cb0f6; border: 2px solid #e5e5e5; border-bottom: 4px solid #e5e5e5; }
.btn.secondary:active { border-bottom-width: 2px; transform: translateY(2px); margin-top: 2px; }
.btn.danger { background: #ff4b4b; border-bottom-color: #ea1515; }
.btn.ok { background: #58cc02; border-bottom-color: #58a700; }
.btn.warn { background: #ffc800; border-bottom-color: #e5b400; color: #fff; }

/* Form Elements */
input, select, textarea { 
    width: 100%; 
    border: 2px solid #e5e5e5; 
    border-radius: 16px; 
    padding: 14px 18px; 
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    background: #f7f7f7; 
    color: #3c3c3c;
    transition: all 0.2s;
    outline: none;
}
input:focus, textarea:focus { border-color: #1cb0f6; background: #ffffff; }
input::placeholder { color: #afafaf; }
textarea { min-height: 100px; resize: vertical; }
.input-sm { max-width: 200px; }

/* Search Box */
.search-box { position: relative; width: 100%; max-width: 320px; }
.search-box input { padding-left: 44px; }
.search-box::before { content: '🔍'; position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 1.1rem; opacity: 0.5; }

/* Tables */
.tablebox { overflow: auto; border-radius: 20px; border: 2px solid #e5e5e5; }
table { width: 100%; border-collapse: collapse; min-width: 780px; background: white; }
th, td { padding: 16px; border-bottom: 2px solid #e5e5e5; text-align: left; vertical-align: middle; }
th { background: #f7f7f7; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; color: #afafaf; font-weight: 800; border-bottom: 2px solid #e5e5e5; }
td.center, th.center { text-align: center; }
tr { transition: background 0.15s; }
tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover { background: #f0f9ff; }
tr:last-child td { border-bottom: none; }

/* Badges */
.badge { display: inline-flex; border-radius: 99px; padding: 6px 12px; font-weight: 800; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; border: 2px solid transparent; }
.badge.ok { background: #d7ffb8; color: #58a700; border-color: #58cc02; }
.badge.wait { background: #ffe1e1; color: #ea1515; border-color: #ff4b4b; }
.badge.warn { background: #fff0b3; color: #b28a00; border-color: #ffc800; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin: 20px 0; }
.stat { background: #ffffff; border: 2px solid #e5e5e5; border-radius: 20px; padding: 18px; box-shadow: 0 4px 0 #e5e5e5; text-align: center; }
.stat span { color: #afafaf; font-weight: 700; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px; }
.stat b { font-size: 1.5rem; color: #3c3c3c; display: block; margin-top: 8px; font-weight: 900; }

/* Alerts */
.alert { border-radius: 16px; padding: 16px 20px; margin-bottom: 20px; font-weight: 700; border: 2px solid transparent; }
.alert.ok { background: #d7ffb8; color: #58a700; border-color: #58cc02; }
.alert.err { background: #ffe1e1; color: #ea1515; border-color: #ff4b4b; }

/* Filter Buttons */
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-btn { 
    background: #ffffff; border: 2px solid #e5e5e5; padding: 10px 18px; border-radius: 99px; 
    font-size: 0.9rem; font-weight: 800; cursor: pointer; transition: all 0.2s; color: #afafaf; 
    text-transform: uppercase; letter-spacing: 0.5px; box-shadow: 0 2px 0 #e5e5e5;
}
.filter-btn:hover { border-color: #1cb0f6; color: #1cb0f6; }
.filter-btn:active { transform: translateY(2px); box-shadow: none; margin-top: 2px; }
.filter-btn.active { background: #1cb0f6; color: white; border-color: #1cb0f6; box-shadow: 0 2px 0 #1899d6; }

/* Specific Helpers */
.text-red { color: #ff4b4b !important; }
.font-bold { font-weight: 800 !important; }
.faltan-datos td { background: #fff4f4 !important; }
.btn-icon { display: none; } /* Oculto porque usaremos modal en la fila entera */
.row-icon { font-size: 1.2rem; opacity: 0.5; transition: 0.2s; }
tr:hover .row-icon { opacity: 1; transform: scale(1.2); }

.mini { max-width: 90px; }
.money { min-width: 130px; max-width: 160px; font-size: 1.1rem; }
.nameinput { min-width: 190px; }

/* Admin Table Overrides for Compact Data View */
.admin-table { min-width: max-content; }
.admin-table th, .admin-table td { padding: 6px 10px; font-size: 0.85rem; border: 1px solid #e5e5e5; white-space: nowrap; }
.admin-table th { background: #f0f0f0; border-bottom: 2px solid #ccc; }
.admin-table input { padding: 4px 8px; font-size: 0.85rem; border-radius: 6px; border: 1px solid #ccc; background: #fff; }
.admin-table input:focus { border-color: #1cb0f6; }
.admin-table td:nth-child(3) { min-width: 180px; font-weight: 700; color: #1cb0f6; }
.admin-table .money { min-width: 100px; max-width: 120px; text-align: right; font-size: 0.9rem; }
.admin-table .nameinput { min-width: 140px; }
.admin-table .mini { max-width: 55px; text-align: center; }

.login-card { max-width: 500px; margin: 40px auto; }
.footer { text-align: center; color: #afafaf; font-weight: 700; padding: 30px; }

/* Modal CSS */
.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: 0.2s; backdrop-filter: blur(4px);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-card {
    background: white; border-radius: 24px; padding: 32px; width: 90%; max-width: 400px;
    border: 2px solid #e5e5e5; box-shadow: 0 8px 0 #e5e5e5, 0 15px 30px rgba(0,0,0,0.2);
    transform: translateY(20px) scale(0.95); transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
}
.modal-overlay.active .modal-card { transform: translateY(0) scale(1); }
.modal-card h3 { font-size: 1.5rem; color: #1cb0f6; margin-bottom: 8px; }
.modal-card p { font-weight: 600; color: #777; margin-bottom: 24px; }
.modal-card .row { justify-content: center; margin-top: 24px; }

@media(max-width: 760px) {
    .grid { grid-template-columns: 1fr; }
    .hero { padding: 24px 20px; }
    .card { padding: 20px; }
    .stats { grid-template-columns: 1fr 1fr; }
}

/* Responsive Table (Card Layout for Mobile) */
@media (max-width: 760px) {
    .tablebox { border: none; overflow: visible; background: transparent; }
    table { background: transparent; min-width: 100%; border: none; }
    thead { display: none; }
    tbody tr { 
        display: flex; flex-direction: column; 
        background: white; border: 2px solid #e5e5e5; border-radius: 20px; 
        margin-bottom: 16px; padding: 16px; box-shadow: 0 4px 0 #e5e5e5;
    }
    tbody tr:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #e5e5e5; }
    tbody td { 
        display: flex; justify-content: space-between; align-items: center; 
        border-bottom: 1px solid #f0f0f0; padding: 10px 0; text-align: right;
    }
    tbody td:last-child { border-bottom: none; }
    tbody td.center { text-align: right; }
    
    /* Create labels on the left side of each cell */
    tbody td::before {
        content: attr(data-label);
        font-weight: 800;
        color: #afafaf;
        text-transform: uppercase;
        font-size: 0.8rem;
        letter-spacing: 0.5px;
        margin-right: 15px;
        text-align: left;
    }
    
    /* Make the student name pop out more on mobile */
    tbody td:nth-child(2) { 
        flex-direction: column; align-items: flex-start; text-align: left; 
        background: #f7f7f7; padding: 16px; border-radius: 16px; margin-bottom: 8px;
    }
    tbody td:nth-child(2)::before { display: none; }
    tbody td:nth-child(2) b { font-size: 1.2rem; color: #1cb0f6; display: block; margin-bottom: 4px; }
}
