/* Reset and base styles v9 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f7;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Header */
.header {
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3a5f 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: white;
}

.logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: white;
}

.logo-icon {
    font-size: 24px;
    margin-right: 8px;
}

.logo-text {
    font-size: 20px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

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

.btn-new:hover, .btn-back:hover, .btn-logout:hover, .btn-primary:hover {
    background: rgba(255,255,255,0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* Container */
.container {
    max-width: 100%;
    padding: 20px;
    margin: 0 auto;
}

/* Auth pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-form, .auth-card {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header .logo-icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    color: #2c5aa0;
}

.auth-header h1 {
    color: #333;
    font-size: 24px;
    font-weight: 600;
}

/* Home page */
.welcome {
    background: white;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.welcome h1 {
    color: #333;
    font-size: 28px;
    margin-bottom: 8px;
}

/* Items list */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.item-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    border-left: 4px solid #2c5aa0;
}

.item-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.item-card.overdue {
    border-left-color: #dc3545;
    background: #fff5f5;
}

.item-card.overdue .item-title {
    color: #dc3545;
    font-weight: bold;
}

.item-card.completed {
    border-left-color: #28a745;
    opacity: 0.8;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 15px;
}

.item-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0;
    flex: 1;
}

.item-badges {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
}

.attachment-badge {
    background: #ffc107;
    color: #212529;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    color: white;
}

.status-new { background: #007bff; }
.status-pending { background: #ffc107; color: #212529; }
.status-under-procurement { background: #6f42c1; }
.status-3rd-party---pending-visit { background: #fd7e14; }
.status-3rd-party---pending-quote { background: #fd7e14; }
.status-3rd-party---pending-approval { background: #fd7e14; }
.status-3rd-party---pending-execution { background: #fd7e14; }
.status-pending-execution-(internal) { background: #6c757d; }
.status-completed { background: #28a745; }

.item-description {
    color: #666;
    font-size: 14px;
    margin-bottom: 12px;
    line-height: 1.5;
}

.item-meta {
    font-size: 12px;
    color: #999;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.expected-date.overdue {
    color: #dc3545;
    font-weight: bold;
}

/* Forms */
.form-container {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s ease;
    background: white;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #2c5aa0;
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* File Upload Styles */
.file-upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f8f9fa;
}

.file-upload-area:hover,
.file-upload-area.drag-over {
    border-color: #2c5aa0;
    background: #f0f4ff;
}

.file-upload-area input[type="file"] {
    display: none;
}

.file-upload-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.upload-icon {
    font-size: 2rem;
    color: #2c5aa0;
}

.file-upload-hint p {
    margin: 0;
    color: #333;
    font-weight: 500;
}

.file-upload-hint small {
    color: #666;
    font-size: 14px;
}

.file-list {
    margin-top: 16px;
    text-align: left;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 8px;
    gap: 12px;
}

.file-icon {
    font-size: 1.25rem;
    color: #2c5aa0;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.file-size {
    color: #666;
    font-size: 12px;
}

/* Attachment actions */
.attachment-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-download {
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-download:hover {
    background: #218838;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-remove-file, .btn-remove-attachment {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    pointer-events: auto;
    z-index: 10;
    position: relative;
}

.btn-remove-file:hover, .btn-remove-attachment:hover {
    background: #c82333;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Ensure forms don't interfere with clicking */
.attachment-actions form {
    margin: 0;
    padding: 0;
    display: inline-block;
}

/* Attachments Display */
.attachments-list {
    margin-top: 12px;
}

.attachment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 8px;
}

.attachment-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.attachment-icon {
    font-size: 1.25rem;
    color: #2c5aa0;
}

.attachment-details {
    flex: 1;
}

.attachment-name a {
    color: #2c5aa0;
    text-decoration: none;
    font-weight: 500;
}

.attachment-name a:hover {
    text-decoration: underline;
}

.attachment-meta {
    color: #666;
    font-size: 12px;
    margin-top: 2px;
}

/* Item details */
.item-details {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 24px;
}

.item-details .item-header {
    border-bottom: 1px solid #e1e5e9;
    padding-bottom: 16px;
    margin-bottom: 20px;
}

/* Status selector */
.status-selector {
    border: 2px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.status-categories {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.status-category-btn {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: #666;
    transition: all 0.2s ease;
}

.status-category-btn.active {
    background: #2c5aa0;
    color: white;
}

.status-category-btn:hover:not(.active) {
    background: #e9ecef;
}

.status-options {
    padding: 16px;
}

.status-group {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
}

.status-group.active {
    display: flex;
}

.status-btn {
    padding: 8px 16px;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    color: #495057;
}

.status-btn:hover {
    border-color: #2c5aa0;
    background: #f0f4ff;
}

.status-btn.active {
    background: #2c5aa0;
    color: white;
    border-color: #2c5aa0;
}

/* Comments */
.comments-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.comments-section h3 {
    margin-bottom: 20px;
    color: #333;
}

.comments-list {
    margin-bottom: 24px;
}

.comment {
    padding: 16px;
    border-radius: 8px;
    background: #f8f9fa;
    margin-bottom: 12px;
    border-left: 3px solid #2c5aa0;
}

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

.comment-header strong {
    color: #2c5aa0;
}

.comment-header small {
    font-size: 12px;
    color: #666;
}

.comment-body {
    color: #333;
    line-height: 1.5;
}

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

.comment-form {
    border-top: 1px solid #e1e5e9;
    padding-top: 20px;
}

.comment-form .btn-primary {
    background: #2c5aa0;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.comment-form .btn-primary:hover {
    background: #1e3a5f;
    transform: translateY(-1px);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.empty-state h2 {
    margin-bottom: 10px;
    color: #333;
}

/* Export */
.export-section {
    margin-top: 40px;
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #e1e5e9;
}

.export-link {
    color: #2c5aa0;
    text-decoration: none;
    font-size: 14px;
    padding: 8px 16px;
    border: 1px solid #2c5aa0;
    border-radius: 6px;
    transition: all 0.2s;
}

.export-link:hover {
    background: #2c5aa0;
    color: white;
}

/* Error messages */
.errors {
    background: #fff5f5;
    color: #dc3545;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #f5c6cb;
}

.errors ul {
    margin: 0;
    padding-left: 20px;
}

.errors li {
    font-size: 14px;
}

/* Success messages */
.success {
    background: #d4edda;
    color: #155724;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #c3e6cb;
}

.success p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* Form button styles */
.form-actions .btn-primary {
    background: #2c5aa0;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.form-actions .btn-primary:hover {
    background: #1e3a5f;
    transform: translateY(-1px);
}

.form-actions .btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

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

/* Auth form specific button styles */
.auth-form .btn-primary {
    background: #2c5aa0;
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.auth-form .btn-primary:hover {
    background: #1e3a5f;
    transform: translateY(-1px);
}

.btn-full {
    width: 100%;
}

/* Auth header improvements */
.auth-header p {
    color: #666;
    margin-top: 8px;
    font-size: 16px;
}

/* Auth links */
.auth-link {
    text-align: center;
    margin-top: 24px;
}

.auth-link p {
    color: #666;
    margin: 0;
}

.auth-link a {
    color: #2c5aa0;
    text-decoration: none;
    font-weight: 500;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* Card styles */
.card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 24px;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .item-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    
    .item-badges {
        align-self: flex-end;
    }
    
    .item-meta {
        flex-direction: column;
        gap: 4px;
    }
    
    .status-group {
        flex-direction: column;
    }
    
    .comment-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .attachment-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .attachment-info {
        flex-direction: column;
        gap: 8px;
    }
}

/* Logo image styles */
.logo-image {
    height: 24px;
    width: auto;
    margin-right: 8px;
    vertical-align: middle;
}

.logo-image-large {
    height: 48px;
    width: auto;
    display: block;
    margin: 0 auto 16px auto;
}