/**
 * CYP TLP System - Main Styles
 */

:root {
    --primary-color: #1976D2;
    --primary-dark: #1565C0;
    --success-color: #4CAF50;
    --danger-color: #f44336;
    --warning-color: #ff9800;
    --text-color: #333;
    --text-light: #666;
    --border-color: #ddd;
    --bg-color: #f5f5f5;
    --white: #fff;
}

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

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 14px;
    color: var(--text-color);
    background: var(--bg-color);
    line-height: 1.5;
}

/* ============================================
   LAYOUT
   ============================================ */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-color);
}

/* ============================================
   NAVBAR
   ============================================ */

.navbar {
    background: var(--primary-color);
    color: var(--white);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar-brand {
    font-size: 18px;
    font-weight: 600;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.navbar-user span {
    font-size: 14px;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    opacity: 0.9;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

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

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

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
}

.btn-secondary {
    background: #6c757d;
    color: var(--white);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ============================================
   FORMS
   ============================================ */

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

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

.form-control {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.1);
}

.form-control-sm {
    padding: 6px 10px;
    font-size: 12px;
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* ============================================
   CARDS
   ============================================ */

.card {
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 16px;
}

.card-body {
    padding: 20px;
}

/* ============================================
   TABLES
   ============================================ */

.table {
    width: 100%;
    border-collapse: collapse;
}

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

.table th {
    font-weight: 600;
    background: var(--bg-color);
    color: var(--text-color);
}

.table tbody tr:hover {
    background: #f8f9fa;
}

.table-clickable tbody tr {
    cursor: pointer;
}

/* ============================================
   BADGES
   ============================================ */

.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
}

.badge-draft {
    background: var(--warning-color);
    color: var(--white);
}

.badge-submitted {
    background: var(--success-color);
    color: var(--white);
}

.badge-email {
    background: #9c27b0;
    color: var(--white);
}

.badge-manual {
    background: #607d8b;
    color: var(--white);
}

/* ============================================
   FILTERS
   ============================================ */

.filters {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 12px;
    color: var(--text-light);
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1976D2 0%, #0d47a1 100%);
}

.login-box {
    background: var(--white);
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo h1 {
    font-size: 24px;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.login-logo p {
    color: var(--text-light);
    font-size: 14px;
}

.login-error {
    background: #ffebee;
    color: var(--danger-color);
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 13px;
    display: none;
}

/* ============================================
   TLP ENTRY PAGE
   ============================================ */

.tlp-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
}

.pdf-viewer-container {
    height: 50%;
    background: #333;
    border-bottom: 2px solid var(--border-color);
}

.pdf-viewer-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.form-container {
    height: 50%;
    overflow-y: auto;
    padding: 20px;
    background: var(--white);
}

/* ============================================
   TLP FORM
   ============================================ */

.tlp-section {
    margin-bottom: 25px;
}

.tlp-section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.tlp-header-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.defect-row {
    display: grid;
    grid-template-columns: 60px 1fr 1fr 120px 120px;
    gap: 10px;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 4px;
    margin-bottom: 10px;
}

.component-row {
    display: grid;
    grid-template-columns: 80px repeat(6, 1fr);
    gap: 10px;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 4px;
    margin-bottom: 10px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
    padding: 12px 15px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.alert-danger {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.alert-warning {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
}

/* ============================================
   MODAL
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--white);
    padding: 25px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ============================================
   LOADING
   ============================================ */

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

.spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .tlp-header-row {
        grid-template-columns: 1fr;
    }
    
    .defect-row {
        grid-template-columns: 1fr;
    }
    
    .component-row {
        grid-template-columns: 1fr;
    }
    
    .filters {
        flex-direction: column;
    }
}
