/* Mobile-First Responsive Design for EVITA Trial Randomisation System */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --background: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Loading Spinner */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Layout */
.page {
    min-height: 100vh;
    padding-bottom: 2rem;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Wider container for user management (desktop-focused) */
#user-management-page .container {
    max-width: 1400px;
}

#user-management-page .form-card {
    max-width: none;
}

/* Wider container for audit logs (desktop-focused) */
#audit-logs-page .container {
    max-width: 1850px;
    padding-left: 2rem;
    padding-right: 2rem;
}

#audit-logs-page .form-card {
    max-width: none;
}

/* Wider container for notification emails (desktop-focused) */
#notification-emails-page .container {
    max-width: 1400px;
    padding-left: 2rem;
    padding-right: 2rem;
}

#notification-emails-page .form-card {
    max-width: none;
}

/* Wider container for LCTC notification emails (desktop-focused) */
#lctc-notification-emails-page .container {
    max-width: 1400px;
    padding-left: 2rem;
    padding-right: 2rem;
}

#lctc-notification-emails-page .form-card {
    max-width: none;
}

/* Navigation Header */
.nav-header {
    background: var(--card-background);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.nav-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
}

/* Login Page Header */
.header {
    text-align: center;
    margin-bottom: 2rem;
    padding-top: 3rem;
}

.header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

/* Cards */
.form-card {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    margin-bottom: 1.5rem;
}

.form-card h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 2rem;
}

.dashboard-card {
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.dashboard-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.dashboard-card .card-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.dashboard-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.dashboard-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.checkbox-group {
    background: #eff6ff;
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid #bfdbfe;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 0.75rem;
    margin-top: 0.25rem;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-primary:disabled:hover {
    background: var(--secondary-color);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.form-actions .btn {
    flex: 1;
}

/* Messages */
.error-message {
    background: #fef2f2;
    color: var(--error-color);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #fecaca;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
}

.success-message {
    background: #f0fdf4;
    color: var(--success-color);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #bbf7d0;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* Result Display */
.result-item {
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-item strong {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.result-item .highlight {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Tablet and Up */
@media (min-width: 640px) {
    .container {
        padding: 2rem;
    }

    .form-card {
        padding: 2rem;
    }

    .nav-header h1 {
        font-size: 1.5rem;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .header {
        padding-top: 4rem;
    }

    .header h1 {
        font-size: 2.5rem;
    }

    .form-card {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        max-width: 800px;
        margin-left: auto;
        margin-right: auto;
    }

    #randomisation-result {
        max-width: 500px;
    }
}

/* Touch-friendly tap targets for mobile */
@media (max-width: 639px) {
    .btn {
        padding: 1rem 1.5rem;
        font-size: 1.0625rem;
    }

    .form-group input,
    .form-group select {
        padding: 1rem;
        font-size: 1.0625rem;
    }

    .dashboard-card {
        padding: 2.5rem 1.5rem;
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

/* User Table */
.user-table-wrapper {
    width: 100%;
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.user-table thead {
    background: var(--primary-color);
    color: white;
}

.user-table th,
.user-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.user-table th {
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-table tbody tr:hover {
    background: #f9fafb;
}

.user-table tbody tr:last-child td {
    border-bottom: none;
}

/* Column width optimizations for desktop */
.user-table th:nth-child(1),
.user-table td:nth-child(1) {
    width: 15%;
}

.user-table th:nth-child(2),
.user-table td:nth-child(2) {
    width: 20%;
}

.user-table th:nth-child(3),
.user-table td:nth-child(3) {
    width: 15%;
}

.user-table th:nth-child(4),
.user-table td:nth-child(4) {
    width: 8%;
    text-align: center;
}

.user-table th:nth-child(5),
.user-table td:nth-child(5) {
    width: 10%;
}

.user-table th:nth-child(6),
.user-table td:nth-child(6) {
    width: 32%;
}

.user-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.user-actions .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    white-space: nowrap;
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-right: 0.5rem;
}

.badge-active {
    background: #d1fae5;
    color: #065f46;
}

.badge-inactive {
    background: #fee2e2;
    color: #991b1b;
}

.badge-role {
    background: #dbeafe;
    color: #1e40af;
}

/* Checkbox List */
.checkbox-list {
    max-height: 200px;
    overflow-y: auto;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    background: var(--background);
}

.checkbox-list label {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    margin: 0;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.checkbox-list label:hover {
    background: white;
}

.checkbox-list input[type="checkbox"] {
    margin-right: 0.75rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Prevent zoom on input focus for iOS */
@supports (-webkit-touch-callout: none) {
    input, select, textarea {
        font-size: 16px;
    }
}

/* Criteria Editor Styles */
.criteria-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.criteria-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.criteria-item input[type="text"] {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

.criteria-item button {
    padding: 0.5rem 0.75rem;
    border: none;
    background: var(--error-color);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
}

.criteria-item button:hover {
    background: #dc2626;
}

.criteria-item.is-deleted {
    opacity: 0.5;
    background: #fee;
}

.criteria-item.is-new {
    background: #efe;
}

.criteria-item.is-modified input[type="text"] {
    background: #fef3c7;
}

.change-preview-list {
    font-size: 0.875rem;
    line-height: 1.6;
}

.change-preview-item {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.change-added {
    background: #d1fae5;
    color: #065f46;
}

.change-removed {
    background: #fee2e2;
    color: #991b1b;
    text-decoration: line-through;
}

.change-modified {
    background: #fef3c7;
    color: #92400e;
}

.eligibility-criteria {
    background: #f9fafb;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary-color);
}

.eligibility-criteria h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.eligibility-criteria ul {
    margin: 0;
    padding-left: 1.5rem;
}

.eligibility-criteria li {
    margin-bottom: 0.25rem;
}

.eligibility-criteria.inclusion {
    border-left-color: #22c55e;
}

.eligibility-criteria.exclusion {
    border-left-color: #ef4444;
}
