/* ===== GLOBAL STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

/* ===== LIGHT MODE ===== */
body.light-mode {
    --bg-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-secondary: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --card-bg: rgba(255, 255, 255, 0.95);
    --card-bg-solid: #ffffff;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --hover-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    --input-bg: #f5f5f5;
    --border-color: #e0e0e0;
    --modal-overlay: rgba(0, 0, 0, 0.5);
    --success-color: #4CAF50;
    --error-color: #f44336;
    --info-color: #2196F3;
    --male-color: #3498db;
    --female-color: #e83e8c;
}

/* ===== DARK MODE ===== */
body.dark-mode {
    --bg-primary: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --bg-secondary: #1e1e2f;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --card-bg: rgba(30, 30, 47, 0.95);
    --card-bg-solid: #2d2d3f;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --hover-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    --input-bg: #2d2d3f;
    --border-color: #3d3d52;
    --modal-overlay: rgba(0, 0, 0, 0.8);
    --success-color: #4CAF50;
    --error-color: #f44336;
    --info-color: #2196F3;
    --male-color: #3498db;
    --female-color: #e83e8c;
}

/* ===== AUTH PAGES (Login va Register) ===== */
.auth-page {
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    animation: fadeInUp 0.6s ease;
}

.auth-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 30px;
    padding: 45px 40px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
}

.auth-header {
    text-align: center;
    margin-bottom: 35px;
}

.auth-header h1 {
    color: var(--text-primary);
    font-size: 2.3em;
    margin-bottom: 12px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 1.1em;
    line-height: 1.5;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95em;
    margin-left: 5px;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-group i {
    position: absolute;
    left: 16px;
    color: var(--text-secondary);
    font-size: 1.1em;
    z-index: 1;
}

.input-group input,
.input-group select,
.input-group textarea {
    width: 100%;
    padding: 15px 20px 15px 48px;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 1em;
    transition: all 0.3s;
}

.input-group select {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 18px center;
    background-size: 16px;
}

.input-group textarea {
    min-height: 80px;
    resize: vertical;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.toggle-password {
    position: absolute;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2em;
    padding: 5px;
    z-index: 2;
    transition: color 0.3s;
}

.toggle-password:hover {
    color: #667eea;
}

.auth-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 16px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s;
    margin-top: 15px;
    width: 100%;
}

.auth-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(102, 126, 234, 0.4);
}

.auth-btn i {
    font-size: 1.2em;
}

.auth-footer {
    text-align: center;
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.auth-footer a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
}

.auth-footer a:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* ===== MAIN APP STYLES ===== */
.app-container {
    min-height: 100vh;
    background: var(--bg-primary);
    padding: 25px;
}

/* Header */
.header {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    padding: 25px 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    animation: slideDown 0.5s ease;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.class-title {
    color: var(--text-primary);
    font-size: 2.2em;
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 700;
}

.class-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 18px;
    border-radius: 40px;
    font-size: 0.45em;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 25px;
}

.theme-toggle {
    background: var(--card-bg-solid);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1.3em;
    cursor: pointer;
    padding: 12px;
    border-radius: 50%;
    transition: all 0.3s;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: rotate(45deg);
    border-color: transparent;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--card-bg-solid);
    padding: 8px 20px 8px 25px;
    border-radius: 50px;
    border: 1px solid var(--border-color);
}

.user-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.1em;
}

.logout-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    padding: 10px 22px;
    border-radius: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
    font-weight: 600;
    font-size: 0.95em;
}

.logout-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(245, 87, 108, 0.4);
}

/* Statistika */
.stats-section {
    margin-bottom: 30px;
    animation: fadeIn 0.8s ease;
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 25px;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--hover-shadow);
}

.stat-icon {
    font-size: 2.8em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.95em;
    margin-bottom: 5px;
}

.stat-value {
    color: var(--text-primary);
    font-size: 2.2em;
    font-weight: 700;
    line-height: 1.2;
}

/* Qidiruv */
.search-section {
    margin-bottom: 30px;
    animation: fadeIn 1s ease;
}

.search-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    position: relative;
    min-width: 280px;
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.1em;
    z-index: 1;
}

.search-box input {
    width: 100%;
    padding: 16px 20px 16px 52px;
    border: none;
    border-radius: 40px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 1em;
    box-shadow: var(--shadow);
    border: 2px solid transparent;
    transition: all 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.search-box input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.add-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 16px 35px;
    border-radius: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1em;
    font-weight: 600;
    transition: all 0.3s;
    white-space: nowrap;
}

.add-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(102, 126, 234, 0.4);
}

/* Students Grid */
.students-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
    animation: fadeInUp 1s ease;
}

/* Student Card */
.student-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.4s ease;
    animation: cardAppear 0.5s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.student-card:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: var(--hover-shadow);
}

.student-card.male-card {
    border-left: 5px solid var(--male-color);
}

.student-card.female-card {
    border-left: 5px solid var(--female-color);
}

.student-card.male-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(90deg, var(--male-color), #9b59b6);
}

.student-card.female-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(90deg, var(--female-color), #fd7e14);
}

.card-image {
    position: relative;
    height: 220px;
    overflow: hidden;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s;
}

.student-card:hover .card-image img {
    transform: scale(1.1);
}

.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.8));
    opacity: 0;
    transition: opacity 0.3s;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 25px;
}

.student-card:hover .card-overlay {
    opacity: 1;
}

.card-actions {
    display: flex;
    gap: 15px;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.student-card:hover .card-actions {
    transform: translateY(0);
}

.edit-btn, .delete-btn {
    background: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    font-size: 1.2em;
}

.edit-btn {
    color: var(--male-color);
}

.delete-btn {
    color: var(--error-color);
}

.edit-btn:hover {
    background: var(--male-color);
    color: white;
    transform: scale(1.15);
}

.delete-btn:hover {
    background: var(--error-color);
    color: white;
    transform: scale(1.15);
}

.card-content {
    padding: 25px;
}

.student-name {
    color: var(--text-primary);
    font-size: 1.3em;
    margin-bottom: 15px;
    font-weight: 700;
}

.student-info {
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95em;
}

.student-info i {
    width: 22px;
    color: #667eea;
    font-size: 1.1em;
}

.student-interests {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.interest-tag {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 16px;
    border-radius: 25px;
    font-size: 0.85em;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* No students message */
.no-students {
    grid-column: 1 / -1;
    text-align: center;
    padding: 70px 30px;
    background: var(--card-bg);
    border-radius: 25px;
    box-shadow: var(--shadow);
}

.no-students i {
    font-size: 5em;
    color: var(--text-secondary);
    margin-bottom: 25px;
    opacity: 0.7;
}

.no-students p {
    color: var(--text-secondary);
    font-size: 1.3em;
    margin-bottom: 25px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-overlay);
    backdrop-filter: blur(8px);
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg-solid);
    border-radius: 30px;
    padding: 35px;
    width: 90%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.4s;
    box-shadow: var(--hover-shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.modal-header h2 {
    color: var(--text-primary);
    font-size: 1.8em;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    font-size: 2.2em;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s;
    line-height: 1;
}

.close-modal:hover {
    color: var(--error-color);
}

#studentForm {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

#studentForm input,
#studentForm select,
#studentForm textarea {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 1em;
    transition: all 0.3s;
}

#studentForm input:focus,
#studentForm select:focus,
#studentForm textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

/* Gender radio buttons */
.gender-group {
    display: flex;
    gap: 25px;
    margin-top: 8px;
    padding: 5px 0;
}

.gender-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 30px;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    transition: all 0.3s;
}

.gender-option:hover {
    border-color: #667eea;
}

.gender-option input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}

.gender-option span {
    color: var(--text-primary);
    font-size: 1em;
    font-weight: 500;
}

.modal-footer {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 25px;
    padding-top: 15px;
    border-top: 2px solid var(--border-color);
}

.cancel-btn {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 14px 28px;
    border-radius: 40px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.cancel-btn:hover {
    background: var(--border-color);
}

.save-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 35px;
    border-radius: 40px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

/* Toast Container */
.toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--card-bg-solid);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    padding: 16px 28px;
    border-radius: 20px;
    box-shadow: var(--hover-shadow);
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideInRight 0.3s;
    min-width: 300px;
    border-left: 5px solid;
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.success i {
    color: var(--success-color);
}

.toast.error {
    border-left-color: var(--error-color);
}

.toast.error i {
    color: var(--error-color);
}

.toast.info {
    border-left-color: var(--info-color);
}

.toast.info i {
    color: var(--info-color);
}

.toast i {
    font-size: 1.5em;
}

.toast span {
    font-size: 1em;
    font-weight: 500;
}

/* Animations */
@keyframes fadeIn {
    from { 
        opacity: 0; 
    }
    to { 
        opacity: 1; 
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, -40%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(102, 126, 234, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .students-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 25px;
    }
    
    .class-title {
        font-size: 2em;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 15px;
    }
    
    .header {
        padding: 20px;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .class-title {
        font-size: 1.8em;
        justify-content: center;
    }
    
    .header-controls {
        width: 100%;
        justify-content: center;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
    }
    
    .search-container {
        flex-direction: column;
    }
    
    .search-box {
        width: 100%;
    }
    
    .add-btn {
        width: 100%;
        justify-content: center;
    }
    
    .modal-content {
        width: 95%;
        padding: 25px;
    }
    
    .student-card:hover {
        transform: translateY(-8px) scale(1.01);
    }
    
    .auth-card {
        padding: 30px 25px;
    }
    
    .auth-header h1 {
        font-size: 2em;
    }
}

@media (max-width: 480px) {
    .class-title {
        font-size: 1.5em;
        flex-direction: column;
        gap: 8px;
    }
    
    .class-badge {
        font-size: 0.7em;
    }
    
    .user-info {
        flex-direction: column;
        padding: 15px;
        width: 100%;
    }
    
    .logout-btn {
        width: 100%;
        justify-content: center;
    }
    
    .stat-card {
        padding: 18px;
    }
    
    .stat-value {
        font-size: 1.8em;
    }
    
    .student-name {
        font-size: 1.2em;
    }
    
    .auth-card {
        padding: 25px 20px;
    }
    
    .gender-group {
        flex-direction: column;
        gap: 12px;
    }
    
    .gender-option {
        width: 100%;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .cancel-btn,
    .save-btn {
        width: 100%;
    }
    
    .toast-container {
        left: 20px;
        right: 20px;
        bottom: 20px;
    }
    
    .toast {
        min-width: auto;
        width: 100%;
    }
}

/* Print styles */
@media print {
    .header-controls,
    .search-section,
    .add-btn,
    .card-overlay,
    .modal,
    .toast-container {
        display: none !important;
    }
    
    .student-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--input-bg);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}