/* Base styles */
:root {
    --primary-color: #007bff;
    --secondary-color: #0056b3;
    --error-color: #d9534f;
    --success-color: #5cb85c;
    --warning-color: #f0ad4e;
    --info-color: #5bc0de;
    --text-color: #333;
    --border-color: #ddd;
    --background-color: #f9f9f9;
}

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

html {
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
}

.container {
    width: 95%;
    margin: 0 auto;
    padding: 0 15px;
}

/* Header styles */
header {
    background-color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 1rem 0;
    margin-bottom: 2rem;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.role {
    color: #FFF;
    font-size: 0.9em;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.nav-link:hover {
    background-color: var(--background-color);
}

/* Form styles */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

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

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

/* Button styles */
.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

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

.btn-secondary {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

/* Table styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--background-color);
    font-weight: 600;
}

tr:hover {
    background-color: rgba(0,0,0,0.02);
}

/* Alert styles */
.error,
.success,
.warning,
.info {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: var(--error-color);
}

.success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: var(--success-color);
}

.warning {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: var(--warning-color);
}

.info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: var(--info-color);
}

/* Loading spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Notification system */
.notification {
    position: relative;
    padding: 1rem 2rem;
    border-radius: 4px;
    color: white;
    animation: slideIn 0.3s ease-out;
    z-index: 1000;
    display: inline-block;
    height: auto;
    min-height: fit-content;
    max-width: 300px;
    white-space: normal;
    word-wrap: break-word;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.notification.success {
    background-color: var(--success-color);
}

.notification.error {
    background-color: var(--error-color);
}

.notification.warning {
    background-color: var(--warning-color);
}

.notification.info {
    background-color: var(--info-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Enhanced Responsive Design */
@media (max-width: 1200px) {
    .container {
        width: 95%;
    }
    
    .projects-table {
        overflow-x: auto;
    }
}

@media (max-width: 992px) {
    .filter-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .date-navigation,
    .filter-controls {
        width: 100%;
        justify-content: flex-start;
    }
    
    .filter-options {
        padding: 1rem;
    }
    
    .filter-group {
        flex: 1 1 calc(50% - 1rem);
        min-width: 200px;
    }
}

@media (max-width: 768px) {
    /* Header and Navigation */
    header .container {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    nav {
        flex-direction: column;
        width: 100%;
        gap: 1rem;
    }
    
    .nav-links {
        width: 100%;
        flex-direction: column;
        align-items: center;
    }
    
    .nav-link {
        width: 100%;
        text-align: center;
        padding: 0.75rem;
    }
    
    .user-info {
        flex-direction: column;
        text-align: center;
        width: 100%;
    }
    
    /* Forms and Tables */
    .form-group {
        margin-bottom: 1.5rem;
    }
    
    input[type="text"],
    input[type="password"],
    input[type="email"],
    select,
    textarea {
        font-size: 16px; /* Prevent zoom on mobile */
        padding: 0.875rem;
    }
    
    .date-inputs,
    .time-inputs {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .date-inputs select,
    .time-inputs select {
        width: 100%;
    }
    
    .checkbox-group,
    .radio-group {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    /* Tables */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    th, td {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    /* Modal */
    .modal-content {
        width: 95%;
        margin: 1rem auto;
        padding: 1rem;
    }
    
    /* Project Cards */
    .project-card {
        width: 100%;
    }
    
    /* Filter Section */
    .filter-options {
        padding: 0.75rem;
    }
    
    .filter-group {
        flex: 1 1 100%;
    }
    
    .filter-label {
        min-width: auto;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 576px) {
    /* Small devices */
    .container {
        width: 100%;
        padding: 0.5rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    /* Buttons */
    .btn-primary {
        width: 100%;
        padding: 0.875rem;
    }
    
    /* Forms */
    .form-group {
        margin-bottom: 1rem;
    }
    
    /* Tables */
    th, td {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    /* Notifications */
    .notification {
        width: 90%;
        left: 5%;
        right: 5%;
        bottom: 1rem;
        max-width: none;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .nav-link,
    .btn-primary,
    .edit-btn,
    .btn-delete {
        padding: 0.875rem 1.25rem; /* Larger touch targets */
    }
    
    input[type="checkbox"],
    input[type="radio"] {
        width: 1.25rem;
        height: 1.25rem;
    }
    
    select {
        padding: 0.875rem;
    }
}

/* Print styles */
@media print {
    header,
    footer,
    .no-print {
        display: none;
    }
    
    body {
        background-color: white;
    }
    
    .container {
        width: 100%;
        max-width: none;
        padding: 0;
    }
    
    table {
        box-shadow: none;
    }
    
    th {
        background-color: white !important;
    }
    
    tr {
        page-break-inside: avoid;
    }
    
    td, th {
        border: 1px solid #000;
        padding: 0.5rem;
    }
    
    a {
        text-decoration: underline;
        color: black !important;
    }
    
    * {
        box-shadow: none !important;
        background-color: white !important;
        color: black !important;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000;
        --secondary-color: #333;
        --text-color: #000;
        --border-color: #000;
        --background-color: #fff;
    }
    
    * {
        border-color: #000 !important;
    }
    
    .btn-primary {
        border: 2px solid #000;
    }
    
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid #000;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
    
    .notification {
        animation: none;
    }
    
    .spinner {
        animation: none;
    }
}

/* Tabs */
.tabs {
    display: flex;
    flex-direction: column;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin: 20px 0;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.tab-navigation {
    display: flex;
    border-bottom: 1px solid #ddd;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.tab-btn {
    padding: 15px 25px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #666;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: #e9ecef;
    color: #333;
}

.tab-btn.active {
    background: white;
    color: #3498db;
    border-bottom: 3px solid #3498db;
}

.tab-content-container {
    padding: 0;
}

.tab-content {
    display: none;
    padding: 20px;
}

.tab-content.active {
    display: block;
}

/* Project Cards */
.projects-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.project-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
}

.color-green {
    border-left: 5px solid #2ecc71;
}

.color-yellow {
    border-left: 5px solid #f1c40f;
}

.color-red {
    border-left: 5px solid #e74c3c;
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.project-code {
    background: #eee;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 14px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
}

/* File Upload */
.file-upload-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.remove-file {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
}

/* Login Page */
.login-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 2rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.login-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-form .form-group {
    margin-bottom: 0;
}

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

.login-form input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

.login-form .btn-primary {
    width: 100%;
    padding: 0.75rem;
    margin-top: 1rem;
    font-size: 1rem;
    font-weight: 500;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.login-form .btn-primary:hover {
    background-color: var(--secondary-color);
}

.login-form .error {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 4px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: var(--error-color);
}

.logo {
    height: 40px;
    width: auto;
}

/* Status styles */
.status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.status.not-submitted {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.status.no-result {
    background-color: #f8d7da;
    color: #721c24;
}

.status.completed {
    background-color: #d1ecf1;
    color: #0c5460;
}

.status.not-completed {
    background-color: #f8f9fa;
    color: #6c757d;
}

/* Type-based completed field background colors */
.radio-group label.type-online-bg {
    background: #d1ecf1 !important;
    border-color: #bee5eb !important;
    color: #0c5460 !important;
}

.radio-group label.type-email-bg {
    background: #d4edda !important;
    border-color: #c3e6cb !important;
    color: #155724 !important;
}

.radio-group label.type-sealed-bg {
    background: #fff3cd !important;
    border-color: #ffeeba !important;
    color: #856404 !important;
}

.radio-group label.type-multiple-bg {
    background: linear-gradient(135deg, #d1ecf1, #d4edda, #fff3cd) !important;
    border-color: #007bff !important;
    color: #495057 !important;
    font-weight: 600 !important;
}

/* Status-based table row background colors */
.projects-table tr.status-submitted {
    background-color: #d4edda !important;
}

.projects-table tr.status-submitted:hover {
    background-color: #c3e6cb !important;
}

.projects-table tr.status-not-submitted {
    background-color: #f8d7da !important;
}

.projects-table tr.status-not-submitted:hover {
    background-color: #f5c6cb !important;
}

.projects-table tr.status-no-result {
    background-color: #fff3cd !important;
}

.projects-table tr.status-no-result:hover {
    background-color: #ffeeba !important;
}

/* Quotes column styles */
.quotes-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 200px;
}

.quotes-text {
    flex: 1;
    font-size: 0.85rem;
    color: #495057;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.quotes-text:hover {
    color: #007bff;
    text-decoration: underline;
}

.no-quotes {
    font-size: 0.85rem;
    color: #6c757d;
    font-style: italic;
}

.quotes-content .btn-icon {
    background: #007bff;
    color: white;
    padding: 0.25rem;
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
}

.quotes-content .btn-icon:hover {
    background: #0056b3;
    transform: scale(1.1);
}