/* =========================
   RESET & BASE
========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f6f8;
    color: #1f2937;
    line-height: 1.5;
}

/* Loading state */
body.loading {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

body.loading::after {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin-top: -25px;
    margin-left: -25px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 9999;
}

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

/* =========================
   CONTAINER
========================= */
.container {
    max-width: 1200px;
    margin: 40px auto;
    background: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 28px;
}

/* =========================
   ANALYTICS DASHBOARD
========================= */
.analytics-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 10px;
    border: 2px solid #e5e7eb;
}

.analytics-section h2 {
    margin-bottom: 20px;
    color: #1f2937;
    font-size: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.chart-box {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border: 1px solid #e5e7eb;
    min-height: 320px;
    display: flex;
    flex-direction: column;
}

.chart-box h3 {
    margin-bottom: 15px;
    font-size: 16px;
    color: #4b5563;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 2px solid #f3f4f6;
}

.chart-container {
    flex: 1;
    position: relative;
    min-height: 250px;
}

/* =========================
   DASHBOARD CARDS
========================= */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.card {
    background: #f9fafb;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    border-left: 6px solid #2563eb;
    transition: transform 0.2s ease;
}

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

.card h3 {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 8px;
}

.card p {
    font-size: 26px;
    font-weight: bold;
    color: #111827;
}

.card.highlight {
    background: #2563eb;
    color: white;
    border-left-color: #1e40af;
}

.card.highlight h3,
.card.highlight p {
    color: white;
}

/* =========================
   COMPANY RESEARCH SECTION
========================= */
.company-research {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 10px;
}

.company-research h2 {
    margin-bottom: 20px;
    color: #1f2937;
}

.research-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.research-btn {
    background-color: #8b5cf6;
    color: white;
    padding: 10px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
}

.research-btn:hover {
    background-color: #7c3aed;
}

.research-search {
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    width: 300px;
}

.research-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.research-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    transition: transform 0.2s;
}

.research-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.research-card h4 {
    color: #2563eb;
    margin-bottom: 10px;
    font-size: 18px;
}

.rating-stars {
    color: #f59e0b;
    font-size: 18px;
    margin: 5px 0;
}

.rating-small {
    color: #f59e0b;
    font-size: 12px;
    margin-top: 5px;
}

/* =========================
   FORM STYLES
========================= */
.form-container {
    background: #f9fafb;
    padding: 25px;
    margin-bottom: 30px;
    border-radius: 10px;
    border: 2px solid #e5e7eb;
}

.form-container h2 {
    margin-bottom: 20px;
    color: #1e40af;
}

.form-section {
    margin: 20px 0;
    padding: 15px;
    background: #f0f9ff;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 200px;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
    color: #4b5563;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 2px solid #d1d5db;
    font-size: 16px;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input.error,
.form-group select.error,
.form-group textarea.error {
    border-color: #ef4444;
}

.form-group .error-message {
    color: #ef4444;
    font-size: 12px;
    margin-top: 4px;
}

.form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-buttons button {
    padding: 12px 24px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    transition: background-color 0.2s;
}

.form-buttons button[type="submit"] {
    background-color: #2563eb;
    color: #ffffff;
}

.form-buttons button[type="submit"]:hover {
    background-color: #1e40af;
}

#cancelBtn {
    background-color: #e5e7eb;
    color: #4b5563;
}

#cancelBtn:hover {
    background-color: #d1d5db;
}

/* =========================
   CONTROLS
========================= */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 25px;
    align-items: center;
}

.controls input,
.controls select {
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    min-width: 180px;
}

#addApplicationBtn {
    background-color: #2563eb;
    color: white;
    padding: 10px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
}

#addApplicationBtn:hover {
    background-color: #1e40af;
}

.secondary-btn {
    background-color: #6b7280;
    color: white;
    padding: 10px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
}

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

/* =========================
   TABLE
========================= */
table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background-color: #f3f4f6;
}

th, td {
    padding: 14px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

tbody tr:hover {
    background-color: #f9fafb;
}

.action-btn {
    background: none;
    border: none;
    color: #2563eb;
    cursor: pointer;
    font-weight: 600;
    margin-right: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.action-btn:hover {
    background-color: #e5e7eb;
    text-decoration: none;
}

.delete-btn {
    color: #dc2626 !important;
}

.delete-btn:hover {
    background-color: #fee2e2 !important;
}

/* =========================
   STATUS BADGES
========================= */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13px;
    display: inline-block;
}

.status-applied {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-interview {
    background: #dcfce7;
    color: #166534;
}

.status-rejected {
    background: #fee2e2;
    color: #991b1b;
}

.status-offer {
    background: #f3e8ff;
    color: #6b21a8;
}

/* =========================
   ALERTS & NOTIFICATIONS
========================= */
.alert.overdue {
    color: #dc2626;
    font-weight: bold;
}

.alert.ok {
    color: #16a34a;
    font-weight: bold;
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    z-index: 1000;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

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

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

/* =========================
   MODAL STYLES
========================= */
.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: 2000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

kbd {
    background-color: #f3f4f6;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    border: 1px solid #d1d5db;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* =========================
   EMPTY STATES
========================= */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 10px;
    font-size: 18px;
    color: #374151;
}

.empty-state p {
    color: #9ca3af;
}

/* =========================
   DAYS REMAINING
========================= */
.days-remaining {
    color: #6b7280;
    font-size: 12px;
}

.days-remaining.overdue {
    color: #dc2626;
    font-weight: bold;
}

/* =========================
   MOBILE RESPONSIVENESS
========================= */
@media (max-width: 768px) {
    .container {
        margin: 20px;
        padding: 20px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .controls input,
    .controls select {
        width: 100%;
        min-width: auto;
    }
    
    .charts-container {
        grid-template-columns: 1fr;
    }
    
    .chart-box {
        min-height: 280px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .form-group {
        min-width: 100%;
    }
    
    table, thead, tbody, th, td, tr {
        display: block;
    }
    
    thead {
        display: none;
    }
    
    tr {
        margin-bottom: 15px;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 10px;
    }
    
    td {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px solid #f3f4f6;
    }
    
    td:last-child {
        border-bottom: none;
    }
    
    td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        margin-right: 10px;
    }
    
    .dashboard {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .card {
        padding: 15px;
    }
    
    .card p {
        font-size: 20px;
    }
    
    .research-cards {
        grid-template-columns: 1fr;
    }
    
    .research-search {
        width: 100%;
    }
    
    .research-header {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Print styles */
@media print {
    .controls,
    .form-container,
    .research-btn,
    .action-btn {
        display: none !important;
    }
    
    .container {
        margin: 0;
        padding: 0;
        box-shadow: none;
    }
    
    table {
        border: 1px solid #000;
    }
}