/* K-12 Loaner Device Checkout System - Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 10px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: linear-gradient(135deg, #001367 0%, #df7300 100%);
    color: white;
    text-align: center;
    padding: 12px 0;
    margin-bottom: 12px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding-left: 10px;
    padding-right: 10px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logout-button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.logout-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.header-logo {
    height: 40px;
    width: auto;
    filter: brightness(0) invert(1);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 300;
    margin: 0;
}

.current-term {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    opacity: 0.9;
}

.term-label {
    font-weight: 500;
}

.term-value {
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.header p {
    font-size: 0.8rem;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
    margin-bottom: 5px;
    flex: 1;
    min-height: 0;
}

.card {
    background: white;
    border-radius: 6px;
    padding: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
    overflow: hidden;
}

.card h2 {
    color: #4a5568;
    margin-bottom: 8px;
    font-size: 1rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 4px;
}

.form-group {
    margin-bottom: 8px;
}

.form-group label {
    display: block;
    margin-bottom: 2px;
    font-weight: 600;
    color: #2d3748;
    font-size: 0.8rem;
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 6px;
    border: 1px solid #e2e8f0;
    border-radius: 3px;
    font-size: 0.85rem;
    transition: border-color 0.3s ease;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-container {
    display: flex;
    gap: 6px;
}

.search-container input {
    flex: 1;
}

.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 3px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #001367 0%, #df7300 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #718096;
    color: white;
}

.btn-secondary:hover {
    background: #4a5568;
}

.btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-success.blocked {
    background: #dc3545;
    color: white;
}

.btn-success.blocked:hover {
    background: #c82333;
}

/* Small buttons in table */
.btn-sm {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 3px;
}

.action-cell {
    text-align: center;
    width: 80px;
}

.ticket-cell {
    text-align: center;
    width: 100px;
}

.ticket-link {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.8rem;
}

.ticket-link:hover {
    text-decoration: underline;
    color: #0056b3;
}

.student-card {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 8px;
    margin-top: 6px;
    display: none;
}

.student-card.show {
    display: block;
}

.student-card h3 {
    color: #2d3748;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.student-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.student-info div {
    padding: 2px 0;
    font-size: 0.75rem;
}

.student-info strong {
    color: #4a5568;
}

/* Policy Status Styles */
.policy-status {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
}

.policy-status h4 {
    margin: 0 0 6px 0;
    font-size: 0.8rem;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.policy-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.policy-status-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    min-width: 50px;
}

.policy-status-badge.clean {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.policy-status-badge.warnings {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.policy-status-badge.dead_battery_limit_exceeded,
.policy-status-badge.forgot_device_limit_exceeded,
.policy-status-badge.late_return_limit_exceeded {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.policy-status-badge.error {
    background-color: #e2e3e5;
    color: #6c757d;
    border: 1px solid #d6d8db;
}

.policy-violations {
    font-size: 0.7rem;
    color: #6c757d;
    line-height: 1.2;
}

.policy-violations div {
    margin: 1px 0;
}

.policy-warning {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 3px;
    padding: 4px 6px;
    font-size: 0.7rem;
    color: #856404;
    line-height: 1.2;
}

.devices-section {
    grid-column: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.devices-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 2px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    flex: 1;
}

.devices-table th,
.devices-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.devices-table th {
    background: #f7fafc;
    font-weight: 600;
    color: #4a5568;
    position: sticky;
    top: 0;
    font-size: 0.75rem;
}

.devices-table td {
    font-size: 0.8rem;
}

.devices-table tr:hover {
    background: #f7fafc;
}

.device-row.unavailable {
    background: #f7fafc;
    color: #a0aec0;
}

.device-row.selected {
    background: #e6fffa;
    border-left: 4px solid #38b2ac;
}

/* Column width adjustments for iPad */
.devices-table th:nth-child(1),  /* # column */
.devices-table td:nth-child(1) {
    width: 40px;
    text-align: center;
}

.devices-table th:nth-child(2),  /* Asset Tag column */
.devices-table td:nth-child(2) {
    width: 100px;
}

.devices-table th:nth-child(3),  /* Status column */
.devices-table td:nth-child(3) {
    width: 80px;
}

.devices-table th:nth-child(4),  /* Checked Out By column */
.devices-table td:nth-child(4) {
    width: 120px;
}

.devices-table th:nth-child(5),  /* Date Out column */
.devices-table td:nth-child(5) {
    width: 100px;
}

.devices-table th:nth-child(6),  /* Select column - wider for iPad */
.devices-table td:nth-child(6) {
    width: 120px;
    text-align: center;
}

.devices-table th:nth-child(7),  /* Ticket column */
.devices-table td:nth-child(7) {
    width: 100px;
    text-align: center;
}

.radio-group {
    text-align: center;
}

.radio-group input[type="radio"] {
    width: auto;
    margin: 0;
}

.right-column {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
}

.checkout-section {
    margin-top: 0;
}

.checkout-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.notes-group {
    grid-column: unset;
}

.notes-group textarea {
    width: 100%;
    padding: 8px;
    border: 2px solid #e2e8f0;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
}

.notes-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.status-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-available {
    background: #c6f6d5;
    color: #22543d;
}

.status-in-use {
    background: #fed7d7;
    color: #742a2a;
}

.status-maintenance {
    background: #fef5e7;
    color: #744210;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.message {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    padding: 12px 20px;
    border-radius: 0;
    margin: 0;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease-in-out;
    transform: translateY(-100%);
}

.message.show {
    transform: translateY(0);
}

.message.success {
    background: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.message.error {
    background: #fed7d7;
    color: #742a2a;
    border: 1px solid #feb2b2;
}

/* iPad 11th generation landscape optimization */
@media (max-width: 1024px) and (orientation: landscape) {
    .container {
        padding: 6px;
    }
    
    .header {
        padding: 6px 0;
        margin-bottom: 6px;
    }
    
    .header-content {
        gap: 10px;
    }
    
    .header-left {
        gap: 10px;
    }
    
    .header-right {
        gap: 8px;
    }
    
    .header-logo {
        height: 30px;
    }
    
    .header h1 {
        font-size: 1.1rem;
        margin: 0;
    }
    
    .current-term {
        font-size: 0.75rem;
        gap: 4px;
    }
    
    .term-value {
        padding: 1px 6px;
        font-size: 0.7rem;
    }
    
    .header p {
        font-size: 0.7rem;
    }
    
    .main-content {
        gap: 8px;
        margin-bottom: 8px;
        grid-template-columns: 1.5fr 1fr;
    }
    
    .card {
        padding: 8px;
    }
    
    .card h2 {
        font-size: 0.9rem;
        margin-bottom: 6px;
        padding-bottom: 3px;
    }
    
    .form-group {
        margin-bottom: 6px;
    }
    
    .form-group label {
        font-size: 0.75rem;
        margin-bottom: 1px;
    }
    
    .form-group select,
    .form-group input {
        padding: 4px;
        font-size: 0.8rem;
    }
    
    .btn {
        padding: 4px 8px;
        font-size: 0.8rem;
    }
    
    .right-column {
        gap: 8px;
    }
    
    .student-card {
        padding: 6px;
        margin-top: 4px;
    }
    
    .student-card h3 {
        font-size: 0.8rem;
        margin-bottom: 3px;
    }
    
    .student-info div {
        font-size: 0.7rem;
        padding: 1px 0;
    }
    
    .devices-table th,
    .devices-table td {
        padding: 3px 6px;
    }
    
    .devices-table th {
        font-size: 0.7rem;
    }
    
    .devices-table td {
        font-size: 0.75rem;
    }
    
    /* Column width adjustments for iPad landscape */
    .devices-table th:nth-child(1),  /* # column */
    .devices-table td:nth-child(1) {
        width: 35px;
    }
    
    .devices-table th:nth-child(2),  /* Asset Tag column */
    .devices-table td:nth-child(2) {
        width: 90px;
    }
    
    .devices-table th:nth-child(3),  /* Status column */
    .devices-table td:nth-child(3) {
        width: 70px;
    }
    
    .devices-table th:nth-child(4),  /* Checked Out By column */
    .devices-table td:nth-child(4) {
        width: 100px;
    }
    
    .devices-table th:nth-child(5),  /* Date Out column */
    .devices-table td:nth-child(5) {
        width: 80px;
    }
    
    .devices-table th:nth-child(6),  /* Select column - wider for iPad */
    .devices-table td:nth-child(6) {
        width: 100px;
    }
    
    .devices-table th:nth-child(7),  /* Ticket column */
    .devices-table td:nth-child(7) {
        width: 80px;
    }
    
    .checkout-section {
        margin-top: 0;
    }
    
    .checkout-form {
        gap: 6px;
        margin-bottom: 8px;
    }
    
    .notes-group textarea {
        min-height: 50px;
        padding: 6px;
        font-size: 0.8rem;
    }
    
    .action-buttons {
        gap: 8px;
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .checkout-form {
        grid-template-columns: 1fr;
    }
    
    .student-info {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
}

/* HTMX Indicators */
.htmx-indicator {
    display: none;
    color: #666;
    font-size: 0.9em;
    margin-top: 5px;
}

.htmx-request .htmx-indicator {
    display: block;
}

.htmx-request.htmx-indicator {
    display: block;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Student search results */
.student-results {
    margin-top: 10px;
}

.student-result-item {
    padding: 8px;
    border: 1px solid #ddd;
    margin: 4px 0;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.student-result-item:hover {
    background-color: #f5f5f5;
}

.no-results {
    padding: 10px;
    color: #666;
    font-style: italic;
}

/* Error messages */
.error {
    color: #d32f2f;
    background-color: #ffebee;
    padding: 8px;
    border-radius: 4px;
    margin: 5px 0;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-in-out;
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-in-out;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #e0e0e0;
    color: #333;
}

.modal-body {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

/* Modal animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Student search modal specific styles */
.modal-search-results {
    max-height: 300px;
    overflow-y: auto;
}

.modal-student-result {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
}

.modal-student-result:hover {
    background: #f8f9fa;
    border-color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15);
}

.modal-student-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    margin-right: 12px;
    flex-shrink: 0;
}

.modal-student-info {
    flex: 1;
}

.modal-student-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    font-size: 1rem;
}

.modal-student-details {
    color: #666;
    font-size: 0.85rem;
    line-height: 1.3;
}

.modal-student-email {
    margin-bottom: 2px;
}

.modal-student-site {
    color: #888;
}

.modal-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

.modal-error {
    text-align: center;
    padding: 40px 20px;
    color: #d32f2f;
    background: #ffebee;
    border-radius: 6px;
    border: 1px solid #ffcdd2;
}

/* Checkin modal specific styles */
.checkin-info {
    padding: 20px 0;
}

.device-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 4px solid #28a745;
}

.device-info h4 {
    margin: 0 0 10px 0;
    color: #28a745;
    font-size: 1.1rem;
}

.device-info p {
    margin: 5px 0;
    font-size: 0.9rem;
}

.device-info strong {
    color: #495057;
}

/* Student warning styles */
.student-warning {
    margin-top: 5px;
    padding: 5px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    border-left: 4px solid #f39c12;
}

.warning-message {
    color: #856404;
    font-size: 0.75rem;
    line-height: 1.4;
}

.warning-message strong {
    color: #d68910;
}
