/* =========================================================
   AJIT9RA — Modern Login + Mobile App Experience
   Load this file AFTER app.css
   ========================================================= */

/* ---------- Modern login ---------- */
.login-panel {
    position: relative;
    overflow: hidden;
}

.login-brand-modern {
    align-items: flex-start;
}

.login-logo {
    display: block;
    width: min(230px, 72vw);
    height: auto;
    max-width: 100%;
    object-fit: contain;
    object-position: left center;
}

.login-copy h1 {
    max-width: 620px;
}

.login-form {
    width: min(560px, 100%);
}

.login-submit {
    min-height: 50px;
    padding: 0 17px;
}

/* ---------- Global safety for touch devices ---------- */
button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

/* ---------- Tablet ---------- */
@media (max-width: 900px) {
    .topbar {
        height: 72px;
        padding: 0 22px;
    }

    .main-content {
        margin-left: 220px;
        width: calc(100% - 220px);
    }

    .sidebar {
        width: 220px;
    }

    .dashboard-hero,
    .kpi-grid,
    .dashboard-grid,
    .page-section {
        padding-left: 22px;
        padding-right: 22px;
    }

    .students-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* =========================================================
   MOBILE — app-like navigation
   ========================================================= */
@media (max-width: 760px) {
    html,
    body {
        min-width: 0;
        overflow-x: hidden;
    }

    body {
        padding-bottom: 78px;
    }

    .app-shell {
        display: block;
        min-height: 100vh;
    }

    /* Bottom navigation */
    .sidebar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        height: 72px;
        min-height: 72px;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
        border-radius: 18px 18px 0 0;
        background: rgba(8, 62, 95, .98);
        box-shadow: 0 -12px 34px rgba(7, 44, 65, .18);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        z-index: 1000;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 4px;
    }

    .sidebar .brand-block {
        display: none;
    }

    .sidebar .nav {
        margin: 0;
        padding: 0 2px;
        flex: 1 1 auto;
        min-width: 0;
        display: flex;
        flex-direction: row;
        align-items: stretch;
        gap: 3px;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .sidebar .nav::-webkit-scrollbar {
        display: none;
    }

    .sidebar .nav a,
    .sidebar .logout-link,
    .sidebar-bottom > a {
        flex: 0 0 68px;
        width: 68px;
        min-height: 58px;
        padding: 7px 4px 6px;
        border-radius: 13px;
        color: rgba(255,255,255,.78);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 3px;
        text-align: center;
        font-size: 17px;
        line-height: 1;
    }

    .sidebar .nav a span,
    .sidebar .logout-link span,
    .sidebar-bottom > a span {
        display: block;
        max-width: 64px;
        overflow: hidden;
        font-size: 9.5px;
        line-height: 1.12;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sidebar .nav a.active,
    .sidebar .nav a:active,
    .sidebar .nav a:hover {
        background: rgba(255,255,255,.13);
        color: #fff;
    }

    .sidebar-bottom {
        margin: 0;
        padding: 0;
        flex: 0 0 auto;
        display: flex;
        flex-direction: row;
        align-items: stretch;
        gap: 2px;
    }

    .sidebar-bottom form {
        display: flex;
        flex: 0 0 auto;
        margin: 0;
        padding: 0;
    }

    .sidebar-bottom .logout-link {
        border: 0;
        background: transparent;
        cursor: pointer;
        font: inherit;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        min-height: 100vh;
    }

    .topbar {
        height: 64px;
        padding: 0 16px;
        position: sticky;
        top: 0;
        z-index: 900;
    }

    .eyebrow {
        font-size: 9px;
    }

    .page-title {
        font-size: 16px;
    }

    .topbar-actions {
        font-size: 11px;
    }

    .dashboard-hero {
        padding: 24px 16px 20px;
        gap: 16px;
    }

    .dashboard-hero h1 {
        font-size: 28px;
        margin-top: 7px;
    }

    .dashboard-hero p {
        font-size: 13px;
        line-height: 1.55;
    }

    .kpi-grid {
        padding: 0 16px 18px;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .kpi-card {
        padding: 14px;
        gap: 10px;
        border-radius: 15px;
    }

    .kpi-icon {
        width: 38px;
        height: 38px;
        border-radius: 11px;
        font-size: 16px;
    }

    .kpi-value {
        font-size: 21px;
    }

    .kpi-label {
        font-size: 10px;
    }

    .dashboard-grid {
        padding: 0 16px 22px;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .panel {
        padding: 16px;
        border-radius: 16px;
    }

    .panel h2 {
        font-size: 15px;
    }

    .panel p {
        font-size: 11px;
    }

    .page-section {
        padding: 22px 16px 30px;
    }

    .page-heading-row {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        margin-bottom: 18px;
    }

    .page-heading-row h1 {
        font-size: 30px;
    }

    .page-heading-row p {
        font-size: 12px;
        line-height: 1.5;
    }

    .students-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px;
        border-radius: 15px;
    }

    .search-form {
        width: 100%;
    }

    .search-form input,
    .ghost-btn,
    .primary-btn,
    .student-form input,
    .student-form select,
    .student-form textarea {
        min-height: 44px;
    }

    .students-count {
        text-align: left;
    }

    .students-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .student-card {
        padding: 15px;
        border-radius: 16px;
    }

    .student-meta {
        grid-template-columns: 1fr 1fr;
        gap: 9px;
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .modal-backdrop {
        padding: 10px;
        align-items: flex-end;
    }

    .modal-card {
        width: 100%;
        max-height: calc(100vh - 20px);
        border-radius: 20px 20px 14px 14px;
        padding: 18px;
    }

    .modal-head h2 {
        font-size: 21px;
    }

    .modal-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .modal-actions .primary-btn,
    .modal-actions .ghost-btn {
        width: 100%;
        min-height: 46px;
    }

    /* Prevent charts/tables from destroying the viewport */
    .panel,
    .student-card,
    .modal-card,
    .report-card,
    .chart-card,
    table {
        max-width: 100%;
    }

    .table-responsive,
    .chart-scroll,
    .timeline-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Login */
    .login-wrap {
        display: block;
        min-height: 100vh;
        background: #f5f8fa;
    }

    .login-panel {
        min-height: 100vh;
        padding: 34px 22px calc(34px + env(safe-area-inset-bottom));
        justify-content: flex-start;
    }

    .login-brand-modern {
        margin-top: 4px;
    }

    .login-logo {
        width: min(220px, 68vw);
        max-height: 96px;
        object-fit: contain;
        object-position: left center;
    }

    .login-copy {
        margin-top: 42px;
    }

    .login-copy h1 {
        font-size: 40px;
        line-height: 1;
        letter-spacing: -.045em;
    }

    .login-copy p {
        font-size: 13px;
        line-height: 1.65;
    }

    .login-form {
        margin-top: 24px;
        gap: 14px;
    }

    .login-form input {
        min-height: 48px;
        padding: 12px 13px;
        border-radius: 12px;
    }

    .login-submit {
        min-height: 50px;
        border-radius: 13px;
    }

    .login-visual {
        display: none;
    }
}

/* Small phones */
@media (max-width: 430px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .student-meta {
        grid-template-columns: 1fr;
    }

    .login-panel {
        padding-left: 18px;
        padding-right: 18px;
    }

    .login-logo {
        width: min(200px, 72vw);
    }

    .login-copy {
        margin-top: 34px;
    }

    .login-copy h1 {
        font-size: 35px;
    }
}
