/* ===================================
   STUDENT CONTACTS PAGE STYLES
   =================================== */

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: #F4F5F7;
    color: #172B4D;
    line-height: 1.5;
}

/* Header Styles */
.header {
    background: white;
    border-bottom: 1px solid #DFE1E6;
    padding: 16px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.logo h1 {
    color: #0052CC;
    font-size: 24px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-btn, .logout-btn {
    background: #F4F5F7;
    color: #42526E;
    border: 1px solid #DFE1E6;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.back-btn:hover, .logout-btn:hover {
    background: #EBECF0;
    border-color: #C1C7D0;
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* Page Header */
.page-header {
    background: white;
    border-radius: 8px;
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: #172B4D;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-subtitle {
    color: #6B778C;
    font-size: 16px;
    margin-bottom: 24px;
}

.student-info {
    background: #F8F9FB;
    padding: 16px;
    border-radius: 6px;
    border-left: 4px solid #36B37E;
}

.student-name {
    font-weight: 600;
    color: #172B4D;
    margin-bottom: 4px;
}

.student-id {
    font-size: 14px;
    color: #6B778C;
    font-family: 'Monaco', 'Consolas', monospace;
}

/* Contacts Section */
.contacts-section {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.contacts-header {
    background: #F8F9FB;
    padding: 24px;
    border-bottom: 1px solid #EBECF0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contacts-title {
    font-size: 20px;
    font-weight: 700;
    color: #172B4D;
    display: flex;
    align-items: center;
    gap: 12px;
}

.contacts-count {
    background: #0052CC;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.add-contact-btn {
    background: #36B37E;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.add-contact-btn:hover {
    background: #00875A;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(54, 179, 126, 0.3);
}

.contacts-content {
    padding: 24px;
}

/* Loading State */
.loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #F4F5F7;
    border-top: 4px solid #0052CC;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Contact List */
.contact-list {
    display: grid;
    gap: 16px;
}

.contact-item {
    background: #FAFBFC;
    border-radius: 8px;
    padding: 20px;
    border-left: 4px solid #DFE1E6;
    transition: all 0.2s ease;
    border: 1px solid #EBECF0;
}

.contact-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.contact-item.primary {
    border-left: 4px solid #36B37E;
    background: #F3FFF7;
}

.contact-item.emergency {
    border-left: 4px solid #FF5722;
    background: #FFF8F5;
}

.contact-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 16px;
}

.contact-name {
    font-size: 18px;
    font-weight: 600;
    color: #172B4D;
    margin-bottom: 4px;
}

.contact-relationship {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #E3F2FD;
    color: #1976D2;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    white-space: nowrap;
}

.contact-relationship.primary {
    background: #E8F5E8;
    color: #2E7D32;
}

.contact-relationship.emergency {
    background: #FFEBE6;
    color: #D84315;
}

.contact-actions {
    display: flex;
    gap: 8px;
}

.contact-action-btn {
    background: none;
    border: 1px solid #DFE1E6;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    color: #6B778C;
}

.contact-action-btn:hover {
    background: #F4F5F7;
    border-color: #C1C7D0;
    color: #172B4D;
}

.contact-action-btn.danger:hover {
    background: #FFEBE6;
    border-color: #FFBDAD;
    color: #DE350B;
}

.contact-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.contact-detail {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #6B778C;
}

.contact-detail-icon {
    width: 16px;
    height: 16px;
    color: #0052CC;
    flex-shrink: 0;
}

.contact-detail-value {
    color: #172B4D;
    font-weight: 500;
}

/* Empty State */
.empty-contacts {
    text-align: center;
    padding: 64px 24px;
    color: #6B778C;
}

.empty-contacts-icon {
    font-size: 64px;
    margin-bottom: 24px;
    color: #DFE1E6;
}

.empty-contacts h3 {
    font-size: 20px;
    margin-bottom: 12px;
    color: #172B4D;
}

.empty-contacts p {
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 24px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.empty-add-btn {
    background: #36B37E;
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.empty-add-btn:hover {
    background: #00875A;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(54, 179, 126, 0.3);
}

/* Contact Form Modal */
.contact-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.contact-modal-content {
    background: white;
    border-radius: 12px;
    padding: 32px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.contact-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #EBECF0;
}

.contact-modal-title {
    font-size: 24px;
    font-weight: 600;
    color: #172B4D;
    margin: 0;
}

.contact-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6B778C;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.contact-modal-close:hover {
    color: #172B4D;
    background: #F4F5F7;
}

/* Contact Form */
.contact-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.contact-form-group {
    display: flex;
    flex-direction: column;
}

.contact-form-group.full-width {
    grid-column: 1 / -1;
}

.contact-form-label {
    font-weight: 600;
    color: #172B4D;
    margin-bottom: 8px;
    font-size: 14px;
}

.contact-form-label.required::after {
    content: " *";
    color: #DE350B;
}

.contact-form-input, .contact-form-select, .contact-form-textarea {
    padding: 12px;
    border: 2px solid #DFE1E6;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: white;
    font-family: inherit;
}

.contact-form-textarea {
    resize: vertical;
    min-height: 80px;
}

.contact-form-input:focus, .contact-form-select:focus, .contact-form-textarea:focus {
    outline: none;
    border-color: #36B37E;
    box-shadow: 0 0 0 3px rgba(54, 179, 126, 0.1);
}

.contact-form-input.error, .contact-form-select.error {
    border-color: #DE350B;
    background: rgba(222, 53, 11, 0.05);
}

.contact-form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #EBECF0;
}

.contact-form-btn {
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.contact-form-btn.primary {
    background: #36B37E;
    color: white;
}

.contact-form-btn.primary:hover:not(:disabled) {
    background: #00875A;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(54, 179, 126, 0.3);
}

.contact-form-btn.secondary {
    background: #F4F5F7;
    color: #42526E;
    border: 1px solid #DFE1E6;
}

.contact-form-btn.secondary:hover {
    background: #EBECF0;
    border-color: #C1C7D0;
}

.contact-form-btn:disabled {
    background: #A5ADBA;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Spinner */
.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

.contact-form-btn.saving .spinner {
    display: inline-block;
}

.contact-form-btn.saving .btn-text {
    display: none;
}

/* Messages */
.error-message, .success-message {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    display: none;
}

.error-message {
    background: #FFEBE6;
    color: #DE350B;
    border: 1px solid #FFBDAD;
}

.success-message {
    background: #E3FCEF;
    color: #006644;
    border: 1px solid #ABF5D1;
}

.error-message.show, .success-message.show {
    display: block;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        padding: 16px;
    }

    .page-header {
        padding: 24px 16px;
    }

    .contacts-header {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .contacts-content {
        padding: 16px;
    }

    .contact-form {
        grid-template-columns: 1fr;
    }

    .contact-modal-content {
        width: 95%;
        padding: 24px;
    }

    .contact-details {
        grid-template-columns: 1fr;
    }

    .contact-item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .contact-actions {
        margin-left: 0;
        width: 100%;
    }

    .page-title {
        font-size: 24px;
    }
}