/* Reset Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: #F8F9FA;
    color: #172B4D;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

html {
    scroll-behavior: smooth;
}

/* Header Styles */
.header {
    background: white;
    border-bottom: 1px solid #EBECF0;
    padding: 10px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo h1 {
    color: #0052CC;
    font-size: 18px;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.welcome-text {
    color: #6B778C;
    font-size: 13px;
    display: none;
}

.logout-btn {
    background: #F4F5F7;
    color: #505F79;
    border: 1px solid #DFE1E6;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: #EBECF0;
    border-color: #C1C7D0;
}

/* Main Content Styles */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px;
    position: relative;
    min-height: 100vh;
}

/* Controls Section */
.controls {
    background: white;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.controls-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.controls-row:last-child {
    margin-bottom: 0;
}

.add-student-btn {
    background: linear-gradient(135deg, #0052CC, #0065FF);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.add-student-btn:hover {
    background: linear-gradient(135deg, #0043A3, #0052CC);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 82, 204, 0.25);
}

.advertising-materials-btn {
    background: linear-gradient(135deg, #00875A, #36B37E);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.advertising-materials-btn:hover {
    background: linear-gradient(135deg, #006644, #00875A);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(54, 179, 126, 0.25);
}

.search-input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid #DFE1E6;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: #FAFBFC;
}

.search-input:focus {
    outline: none;
    border-color: #0052CC;
    background: white;
    box-shadow: 0 0 0 2px rgba(0, 82, 204, 0.1);
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid #DFE1E6;
    border-radius: 6px;
    font-size: 13px;
    background: #FAFBFC;
    cursor: pointer;
    min-width: 120px;
}

.filter-select:focus {
    outline: none;
    border-color: #0052CC;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    color: #6B778C;
    font-size: 12px;
    flex-wrap: wrap;
}

.stat-item {
    background: #F4F5F7;
    padding: 5px 10px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 12px;
}

.stat-attention {
    background: #FFEBE6;
    color: #DE350B;
}

/* Students Grid */
.students-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
    position: relative;
}

/* Student Card - Ultra Compact */
.student-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.15s ease;
    cursor: pointer;
    opacity: 0;
    transform: translateY(6px);
    animation: fadeInUp 0.25s ease forwards;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.student-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.08);
}

.student-card:active {
    transform: scale(0.99);
}

.student-card.attention {
    border-left: 2px solid #DE350B;
}

.student-card.normal {
    border-left: 2px solid #36B37E;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-main-content {
    padding: 10px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.student-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    gap: 6px;
}

.student-info {
    flex: 1;
    min-width: 0;
}

.student-name {
    font-size: 13px;
    font-weight: 600;
    color: #172B4D;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.student-passport {
    font-size: 10px;
    color: #97A0AF;
    font-family: 'Monaco', 'Consolas', monospace;
    letter-spacing: 0.3px;
    margin-top: 1px;
}

.attention-badge {
    background: linear-gradient(135deg, #DE350B, #FF5630);
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.normal-badge {
    background: linear-gradient(135deg, #00875A, #36B37E);
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.student-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    line-height: 1.2;
    padding: 1px 0;
    border-bottom: 1px solid rgba(0,0,0,0.03);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: #97A0AF;
    font-weight: 500;
    flex-shrink: 0;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.2px;
}

.detail-value {
    color: #42526E;
    font-weight: 500;
    text-align: right;
    max-width: 68%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10px;
}

.record-id {
    background: #F4F5F7;
    color: #A5ADBA;
    padding: 3px 8px;
    font-size: 8px;
    font-family: 'Monaco', 'Consolas', monospace;
    text-align: center;
    border-top: 1px solid #EBECF0;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* Loading States */
.loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #F4F5F7;
    border-top: 3px solid #0052CC;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.load-more-container {
    display: flex;
    justify-content: center;
    padding: 24px;
    background: rgba(244, 245, 247, 0.6);
    border-radius: 8px;
    margin: 16px 0;
}

.load-more-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #F4F5F7;
    border-top: 2px solid #0052CC;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #6B778C;
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.04);
    margin: 16px 0;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #0052CC, #0065FF);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: #172B4D;
    font-weight: 600;
}

.empty-state-description {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 24px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    color: #6B778C;
}

.empty-state-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.empty-state-btn {
    background: #0052CC;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.empty-state-btn:hover {
    background: #0043A3;
    transform: translateY(-1px);
}

.empty-state-btn.secondary {
    background: #F4F5F7;
    color: #42526E;
    border: 1px solid #DFE1E6;
}

.empty-state-btn.secondary:hover {
    background: #EBECF0;
    border-color: #C1C7D0;
}

.refresh-icon {
    width: 14px;
    height: 14px;
    transition: transform 0.3s ease;
}

.empty-state-btn.secondary:hover .refresh-icon {
    transform: rotate(180deg);
}

/* Error Message */
.error-message {
    background: #FFEBE6;
    color: #DE350B;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 12px;
    text-align: center;
    font-size: 13px;
}

/* ========================================
   RESPONSIVE STYLES
   ======================================== */

/* Large tablets and small desktops */
@media (min-width: 769px) {
    .welcome-text {
        display: block;
    }
}

/* Tablets */
@media (max-width: 768px) {
    .header {
        padding: 10px 12px;
    }

    .header-content {
        flex-wrap: wrap;
    }

    .logo h1 {
        font-size: 16px;
    }

    .main-content {
        padding: 10px;
    }

    .controls {
        padding: 10px;
    }

    .controls-row {
        gap: 6px;
    }

    .add-student-btn,
    .advertising-materials-btn {
        padding: 8px 12px;
        font-size: 12px;
        flex: 1;
        justify-content: center;
    }

    .search-input {
        width: 100%;
        order: -1;
        margin-bottom: 6px;
    }

    .filter-select {
        flex: 1;
        min-width: 0;
    }

    .stats-bar {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .stat-item {
        flex-shrink: 0;
    }

    .students-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 8px;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    .header {
        padding: 6px 10px;
    }

    .logo h1 {
        font-size: 14px;
    }

    .logout-btn {
        padding: 5px 8px;
        font-size: 11px;
    }

    .main-content {
        padding: 6px;
    }

    .controls {
        padding: 6px;
        margin-bottom: 6px;
        border-radius: 6px;
    }

    .controls-row {
        gap: 4px;
        margin-bottom: 6px;
    }

    .controls-row:last-child {
        margin-bottom: 0;
    }

    .add-student-btn,
    .advertising-materials-btn {
        padding: 7px 10px;
        font-size: 11px;
        min-height: 36px;
    }

    .search-input {
        padding: 8px 10px;
        font-size: 16px; /* Prevents zoom on iOS */
        margin-bottom: 4px;
    }

    .filter-select {
        padding: 7px 6px;
        font-size: 11px;
        min-height: 36px;
    }

    .stats-bar {
        gap: 4px;
        font-size: 10px;
        margin-top: 4px;
    }

    .stat-item {
        padding: 3px 6px;
        font-size: 10px;
    }

    .students-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .student-card {
        border-radius: 6px;
    }

    .card-main-content {
        padding: 8px 10px;
    }

    .student-header {
        margin-bottom: 4px;
    }

    .student-name {
        font-size: 13px;
    }

    .student-passport {
        font-size: 9px;
    }

    .student-details {
        gap: 0;
    }

    .detail-row {
        padding: 0;
        line-height: 1.15;
    }

    .detail-label {
        font-size: 8px;
    }

    .detail-value {
        font-size: 9px;
        max-width: 62%;
    }

    /* Hide less important details on mobile */
    .student-details .detail-row:nth-child(n+6) {
        display: none;
    }

    .attention-badge,
    .normal-badge {
        font-size: 8px;
        padding: 2px 5px;
    }

    .record-id {
        padding: 2px 6px;
        font-size: 7px;
    }

    .empty-state {
        padding: 32px 16px;
        margin: 8px 0;
    }

    .empty-state-icon {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }

    .empty-state h3 {
        font-size: 16px;
    }

    .empty-state-description {
        font-size: 13px;
    }

    .empty-state-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .empty-state-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
    }
}

/* Extra small phones */
@media (max-width: 360px) {
    .header {
        padding: 5px 8px;
    }

    .header-content {
        gap: 4px;
    }

    .logo h1 {
        font-size: 13px;
    }

    .logout-btn {
        padding: 4px 6px;
        font-size: 10px;
    }

    .main-content {
        padding: 4px;
    }

    .controls {
        padding: 5px;
        margin-bottom: 4px;
    }

    .controls-row {
        gap: 3px;
        margin-bottom: 4px;
    }

    .add-student-btn,
    .advertising-materials-btn {
        font-size: 10px;
        padding: 6px 8px;
        min-height: 32px;
    }

    .search-input {
        padding: 7px 8px;
    }

    .filter-select {
        padding: 6px 4px;
        font-size: 10px;
        min-height: 32px;
    }

    .stats-bar {
        gap: 3px;
    }

    .stat-item {
        padding: 2px 5px;
        font-size: 9px;
    }

    .students-grid {
        gap: 4px;
    }

    .card-main-content {
        padding: 6px 8px;
    }

    .student-name {
        font-size: 12px;
    }

    .student-passport {
        font-size: 8px;
    }

    .detail-label {
        font-size: 8px;
    }

    .detail-value {
        font-size: 9px;
    }

    .attention-badge,
    .normal-badge {
        font-size: 7px;
        padding: 1px 4px;
        border-radius: 6px;
    }

    .record-id {
        font-size: 6px;
        padding: 2px 4px;
    }

    /* Hide more details on very small screens - show only 4 rows */
    .student-details .detail-row:nth-child(n+5) {
        display: none;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .student-card:hover {
        transform: none;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    }

    .student-card:active {
        transform: scale(0.98);
        background: #FAFBFC;
    }

    .add-student-btn:hover,
    .advertising-materials-btn:hover,
    .empty-state-btn:hover {
        transform: none;
    }

    /* Larger touch targets */
    .filter-select,
    .search-input {
        min-height: 44px;
    }

    .add-student-btn,
    .advertising-materials-btn {
        min-height: 44px;
    }

    .logout-btn {
        min-height: 40px;
    }
}

/* Landscape mode on phones */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        padding: 6px 12px;
    }

    .main-content {
        padding: 8px;
    }

    .controls {
        padding: 8px;
        margin-bottom: 8px;
    }

    .students-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    /* Future dark mode styles can go here */
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .student-card {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .student-card:hover {
        transform: none;
    }

    * {
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .student-card {
        border: 2px solid #172B4D;
    }

    .attention-badge,
    .normal-badge {
        border: 1px solid currentColor;
    }
}

/* Print styles */
@media print {
    .header,
    .controls,
    .empty-state-actions {
        display: none;
    }

    .main-content {
        padding: 0;
    }

    .students-grid {
        display: block;
    }

    .student-card {
        break-inside: avoid;
        margin-bottom: 10px;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
