/* ===================================
   Component Styles
   - Buttons
   - Forms
   - Alerts
   - Feature Cards
   - Modals
   - Student Search
   =================================== */

/* ==================== Buttons ==================== */

.btn-primary {
    background-color: var(--primary-color);
    color: white !important;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.3s, box-shadow 0.3s;
}

.btn-primary:hover {
    background-color: #357ae8;
    box-shadow: var(--shadow-hover);
}

.btn-secondary {
    background-color: white;
    color: var(--text-color);
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.3s, box-shadow 0.3s;
}

.btn-secondary:hover {
    background-color: var(--background-secondary);
    box-shadow: var(--shadow);
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.3s, box-shadow 0.3s;
}

.btn-danger:hover {
    background-color: #c82333;
    box-shadow: var(--shadow-hover);
}

.btn-success {
    background-color: var(--secondary-color);
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.3s, box-shadow 0.3s;
}

.btn-success:hover {
    background-color: #2d9348;
    box-shadow: var(--shadow-hover);
}

/* ==================== Forms ==================== */

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="file"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Character Counter */
.char-counter {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: right;
    transition: color 0.2s ease;
}

.char-counter .char-count {
    font-weight: 600;
}

.char-counter.warning {
    color: #f57c00;
}

.char-counter.danger {
    color: #d32f2f;
}

/* Date Input */
.form-group input.date-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    background-color: white;
    color: var(--text-color);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input.date-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.form-group input.date-input::placeholder {
    color: #999;
}

/* ==================== Alerts ==================== */

.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.alert-warning {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.alert-info {
    background-color: #d1ecf1;
    border: 1px solid #17a2b8;
    color: #0c5460;
}

/* ==================== Feature Cards ==================== */

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin: 3rem 0;
}

.feature-card {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.3s, transform 0.3s;
}

.feature-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.feature-card h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.feature-card p {
    color: var(--text-secondary);
}

/* ==================== Modals ==================== */

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    width: 100%;
    max-width: 600px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close {
    color: var(--text-secondary);
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 1.5rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* ==================== Student Search ==================== */

.student-search-wrapper {
    position: relative;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: var(--shadow);
    z-index: 100;
}

.search-result-item {
    padding: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: var(--background-secondary);
}

.selected-student {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--background-secondary);
    border-radius: 4px;
    margin-top: 0.5rem;
}

.clear-student {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.clear-student:hover {
    background: #c82333;
}

.selected-students {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    min-height: 36px;
}

.student-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--primary-color);
    color: white;
    border-radius: 16px;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.student-tag:hover {
    background: #357ae8;
}

.student-tag .remove-student {
    background: rgba(255, 255, 255, 0.3);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
    padding: 0;
    line-height: 1;
}

.student-tag .remove-student:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* ==================== Responsive ==================== */

@media (max-width: 768px) {
    .features {
        grid-template-columns: 1fr;
    }

    .modal-content {
        margin: 10% 1rem;
        max-width: 100%;
    }
}
