/**
 * VBS Team Management System - Styles
 */

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --light-bg: #ecf0f1;
    --dark-text: #2c3e50;
    --light-text: #7f8c8d;
    --border-color: #bdc3c7;
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark-text);
}

/* Login Page Background */
body.login-page {
    background-image: url('../../img/bglogin.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    position: relative;
}

body.login-page::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 0;
}

body.login-page > * {
    position: relative;
    z-index: 1;
}

/* Thai Font Support */
body.thai-lang {
    font-family: 'Sarabun', 'Sukhumvit Set', 'Thonburi', sans-serif;
}

/* ============================================================================
   Login Page
   ============================================================================ */

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    position: relative;
    z-index: 2;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 50px 40px;
    width: 100%;
    max-width: 450px;
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.logo {
    max-width: 120px;
    height: auto;
    margin-bottom: 20px;
}

.company-name {
    font-size: 32px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 5px;
}

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

/* Language Selector Inline (inside login card) */
.language-selector-inline {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.language-selector-inline select {
    border: 2px solid var(--border-color);
    background: white;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    padding: 8px 12px;
    border-radius: 8px;
    transition: var(--transition);
}

.language-selector-inline select:hover {
    border-color: var(--secondary-color);
}

.language-selector-inline select:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark-text);
}

.form-control {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.error-message {
    background: #fdecea;
    color: var(--danger-color);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
    border-left: 4px solid var(--danger-color);
}

.error-message.show {
    display: block;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* ============================================================================
   Dashboard Layout
   ============================================================================ */

.dashboard-container {
    display: flex;
    min-height: 100vh;
    background: var(--light-bg);
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--primary-color);
    color: white;
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.sidebar-logo {
    max-width: 60px;
    height: auto;
    margin-bottom: 10px;
}

.sidebar-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 5px;
}

.sidebar-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.nav-menu {
    list-style: none;
}

.nav-item {
    margin-bottom: 5px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: var(--transition);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-link.active {
    background: var(--secondary-color);
    color: white;
}

.nav-icon {
    margin-right: 12px;
    font-size: 20px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 30px;
}

.topbar {
    background: white;
    padding: 20px 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: var(--card-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar-left h1 {
    font-size: 28px;
    color: var(--primary-color);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.language-switch {
    padding: 8px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: var(--transition);
}

.language-switch:hover {
    border-color: var(--secondary-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

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

.stat-label {
    font-size: 14px;
    color: var(--light-text);
    font-weight: 600;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.blue { background: rgba(52, 152, 219, 0.1); color: var(--secondary-color); }
.stat-icon.green { background: rgba(39, 174, 96, 0.1); color: var(--success-color); }
.stat-icon.orange { background: rgba(243, 156, 18, 0.1); color: var(--warning-color); }
.stat-icon.red { background: rgba(231, 76, 60, 0.1); color: var(--danger-color); }

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-change {
    font-size: 12px;
    margin-top: 5px;
}

.stat-change.positive { color: var(--success-color); }
.stat-change.negative { color: var(--danger-color); }

/* Content Cards */
.content-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: var(--card-shadow);
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--light-bg);
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
}

/* Tables */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

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

/* Sticky column support */
table td[style*="position: sticky"],
table th[style*="position: sticky"] {
    border-right: 2px solid var(--border-color);
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
}

thead {
    background: var(--light-bg);
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--dark-text);
}

td {
    padding: 15px;
    border-bottom: 1px solid var(--light-bg);
}

tr:hover {
    background: rgba(52, 152, 219, 0.05);
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: rgba(39, 174, 96, 0.1); color: var(--success-color); }
.badge-warning { background: rgba(243, 156, 18, 0.1); color: var(--warning-color); }
.badge-danger { background: rgba(231, 76, 60, 0.1); color: var(--danger-color); }
.badge-info { background: rgba(52, 152, 219, 0.1); color: var(--secondary-color); }

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--light-bg);
    border-top: 4px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 80px;
    }
    
    .main-content {
        margin-left: 80px;
    }
    
    .sidebar-title,
    .sidebar-subtitle,
    .nav-link span {
        display: none;
    }
    
    .nav-link {
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 30px 20px;
    }
    
    .company-name {
        font-size: 24px;
    }
}

/* Employee Dashboard - Current Event Display */
.current-event-display {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.event-info-section {
    background: white;
    padding: 25px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.event-title-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.event-name {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    color: var(--primary-color);
}

.event-id-badge {
    background: var(--secondary-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.event-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.detail-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--light-bg);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #dfe6e9;
}

.detail-icon {
    font-size: 24px;
    line-height: 1;
}

.detail-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--light-text);
    font-weight: 600;
}

.detail-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark-text);
}

.event-description {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid var(--secondary-color);
}

.event-description h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--dark-text);
    font-weight: 600;
}

.event-description p {
    margin: 0;
    line-height: 1.6;
    color: var(--dark-text);
    font-size: 15px;
}

.event-action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-event-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-event-link .btn-icon {
    font-size: 18px;
}

.btn-cockpit {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-cockpit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-zeitplan {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-zeitplan:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.4);
}

.btn-ergebnisse {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-ergebnisse:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.4);
}

.btn-disabled {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    color: rgba(255, 255, 255, 0.6);
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-disabled:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Work Schedule Section */
.work-schedule-section {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
}

.title-icon {
    font-size: 24px;
}

.work-schedule-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.work-schedule-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--light-bg);
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
    gap: 15px;
    flex-wrap: wrap;
}

.schedule-date {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 180px;
}

.schedule-date strong {
    font-size: 15px;
    color: var(--dark-text);
}

.schedule-time {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.time-input-small {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.time-input-small:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.btn-icon {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(52, 152, 219, 0.1);
    transform: scale(1.1);
}

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

/* Responsive Design for Current Event */
@media (max-width: 768px) {
    .event-details-grid {
        grid-template-columns: 1fr;
    }
    
    .event-action-buttons {
        flex-direction: column;
    }
    
    .btn-event-link {
        width: 100%;
        justify-content: center;
    }
    
    .work-schedule-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .schedule-time {
        width: 100%;
    }
}

/* Calendar Grid Styles */
.calendar {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    text-align: center;
}

.calendar-weekday {
    padding: 12px;
    font-size: 14px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.calendar-weekday:last-child {
    border-right: none;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    background: white;
}

.calendar-day {
    min-height: 100px;
    padding: 10px;
    border: 1px solid #e0e0e0;
    background: white;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.calendar-day.empty {
    background: #f8f9fa;
}

.calendar-day.today {
    background: #fff9e6;
    border: 2px solid #f39c12;
}

.calendar-day.past {
    opacity: 0.6;
}

.calendar-day:hover:not(.empty) {
    box-shadow: inset 0 0 0 2px var(--secondary-color);
    transform: scale(1.02);
    z-index: 10;
}

/* Enhanced Calendar Styles */
.calendar-day.my-event {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 2px solid #27ae60;
}

.calendar-day.other-event {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    border: 2px solid #95a5a6;
}

.day-number {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark-text);
    margin-bottom: 5px;
}

.day-events {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 5px;
}

.day-event-badge {
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    color: white;
}

.day-event-badge.mine {
    background: #27ae60;
}

.day-event-badge.other {
    background: #95a5a6;
}

.day-event-more {
    font-size: 10px;
    color: var(--light-text);
    font-weight: 600;
    text-align: center;
    margin-top: 2px;
}

/* Event Detail Modal */
.modal-event-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.my-event-card {
    border-left: 5px solid #27ae60;
    background: linear-gradient(135deg, #f0f9f4 0%, #ffffff 100%);
}

.other-event-card {
    border-left: 5px solid #95a5a6;
}

.modal-event-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.modal-event-header h3 {
    margin: 0;
    font-size: 22px;
    color: var(--primary-color);
}

.modal-event-info {
    display: grid;
    gap: 15px;
    margin-bottom: 20px;
}

.info-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: var(--light-bg);
    border-radius: 8px;
}

.info-icon {
    font-size: 20px;
    line-height: 1;
}

.info-row > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--light-text);
    font-weight: 600;
}

.info-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--dark-text);
}

.modal-event-description {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.modal-event-description strong {
    display: block;
    margin-bottom: 8px;
    color: var(--dark-text);
    font-size: 14px;
}

.modal-event-description p {
    margin: 0;
    line-height: 1.6;
    color: var(--dark-text);
}

.modal-event-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.modal-staff-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.modal-staff-section h4 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: var(--dark-text);
}

.staff-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.staff-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--light-bg);
    border-radius: 8px;
    border-left: 3px solid var(--border-color);
}

.staff-item.highlighted {
    background: #d4edda;
    border-left-color: #27ae60;
}

.staff-name {
    font-weight: 600;
    color: var(--dark-text);
    font-size: 15px;
}

.staff-details {
    display: flex;
    gap: 15px;
    font-size: 14px;
    color: var(--light-text);
}

.no-staff {
    color: var(--light-text);
    font-style: italic;
    margin: 10px 0 0 0;
}

/* Responsive Calendar */
@media (max-width: 768px) {
    .calendar-day {
        min-height: 80px;
        padding: 6px;
    }
    
    .day-number {
        font-size: 14px;
    }
    
    .day-event-badge {
        font-size: 10px;
        padding: 3px 5px;
    }
}

@media (max-width: 480px) {
    .calendar-day {
        min-height: 60px;
        padding: 4px;
    }
    
    .calendar-weekday {
        padding: 8px;
        font-size: 12px;
    }
    
    .day-number {
        font-size: 12px;
    }
}

/* Responsive Modal */
@media (max-width: 768px) {
    .modal-event-links {
        flex-direction: column;
    }
    
    .btn-event-link {
        width: 100%;
        justify-content: center;
    }
    
    .staff-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .staff-details {
        flex-direction: column;
        gap: 5px;
    }
}
