/**
 * Enterprise HRM ERP System - Main Stylesheet
 * Excel-like UI with clean, modern design
 */

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

:root {
    --primary-color: #1e293b;
    --primary-dark: #1e40af;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --bg-color: #f8fafc;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --white: #ffffff;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-color);
    overflow-x: hidden; /* Prevent body horizontal scroll */
    width: 100%;
    position: relative;
}

/* Responsive: Tablet and below */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
        min-width: 240px;
        max-width: 240px;
    }
    
    .main-content {
        margin-left: 240px;
        width: calc(100% - 240px);
    }
    
    .content-wrapper {
        padding: 32px 40px;
    }
    
    .card {
        padding: 28px 32px;
        margin-bottom: 28px;
    }
}

/* Responsive: Mobile */
@media (max-width: 768px) {
    .sidebar {
        width: 260px;
        min-width: 260px;
        max-width: 260px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1001;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .content-wrapper {
        padding: 20px 15px;
    }
    
    .top-bar {
        padding: 15px 20px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .top-bar h1 {
        font-size: 18px;
        order: 2;
        flex: 1;
    }
    
    .top-bar-actions {
        order: 3;
        width: 100%;
        justify-content: space-between;
    }
    
    .mobile-menu-toggle {
        display: flex !important;
        order: 1;
    }
    
    .card {
        padding: 20px 15px;
        margin-bottom: 20px;
        border-radius: 8px;
    }
    
    .card-header {
        padding-bottom: 15px;
        margin-bottom: 20px;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .card-title {
        font-size: 16px;
    }
    
    .alert {
        margin: 15px;
        padding: 12px 15px;
        font-size: 13px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .form-control {
        padding: 10px 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 8px;
}

.mobile-menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: white;
    position: relative;
}

.mobile-menu-toggle span::before,
.mobile-menu-toggle span::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background: white;
    left: 0;
}

.mobile-menu-toggle span::before {
    top: -6px;
}

.mobile-menu-toggle span::after {
    top: 6px;
}

/* Small Mobile (480px and below) */
@media (max-width: 480px) {
    .top-bar {
        padding: 12px 15px;
    }
    
    .top-bar h1 {
        font-size: 16px;
    }
    
    .content-wrapper {
        padding: 15px 10px;
    }
    
    .card {
        padding: 15px 12px;
        margin-bottom: 15px;
    }
    
    .card-title {
        font-size: 14px;
    }
    
    .btn {
        padding: 10px 14px;
        font-size: 12px;
    }
    
    .current-time {
        font-size: 11px;
    }
    
    .sidebar-header h2 {
        font-size: 16px;
    }
}

.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
}

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

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

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

.sidebar-nav {
    flex: 1;
    padding: 10px 0;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin: 2px 10px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
}

.sidebar-nav a:hover {
    background-color: var(--sidebar-hover);
    color: var(--white);
}

.sidebar-nav li.active a {
    background-color: var(--primary-color);
    color: var(--white);
}

.sidebar-nav .icon {
    margin-right: 10px;
    font-size: 18px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    margin-bottom: 15px;
}

.user-info p {
    margin: 5px 0;
    font-size: 13px;
}

.user-info .role {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
}

.btn-logout {
    display: block;
    width: 100%;
    padding: 10px;
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--white);
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.btn-logout:hover {
    background-color: rgba(239, 68, 68, 0.3);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    width: calc(100% - 260px);
    min-width: 0; /* Critical for flexbox overflow */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden; /* Prevent horizontal overflow at main level */
    background-color: var(--bg-color);
}

.top-bar {
    background-color: var(--white);
    padding: 24px 40px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    margin-bottom: 0;
}

.top-bar h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.current-time {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.content-wrapper {
    flex: 1;
    padding: 40px 50px;
    overflow-x: auto;
    overflow-y: visible;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* Ensure content doesn't overflow under sidebar */
    position: relative;
}

/* Optional: Max-width container for better readability on large screens */
.content-wrapper > .card,
.content-wrapper > .table-container {
    max-width: 1800px;
    margin-left: auto;
    margin-right: auto;
}

/* Alerts */
.alert {
    margin: 24px 50px;
    padding: 16px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow);
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success-color);
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--error-color);
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning-color);
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--info-color);
}

.alert-icon {
    font-weight: bold;
    font-size: 16px;
}

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

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

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

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

.btn-success:hover {
    background-color: #059669;
}

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

.btn-danger:hover {
    background-color: #dc2626;
}

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

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

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

/* Forms */
.form-group {
    margin-bottom: 24px;
}

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

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

.form-control:hover {
    border-color: #cbd5e1;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control:disabled {
    background-color: #f1f5f9;
    cursor: not-allowed;
    opacity: 0.6;
}

select.form-control {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23374151' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
    appearance: none;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.form-error {
    color: var(--error-color);
    font-size: 12px;
    margin-top: 6px;
    display: block;
}

/* Cards */
.card {
    background-color: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 32px 40px;
    margin-bottom: 32px;
    border: 1px solid var(--border-color);
}

.card-header {
    padding-bottom: 24px;
    margin-bottom: 28px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.4;
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }
.mr-1 { margin-right: 10px; }
.mr-2 { margin-right: 20px; }

.d-flex {
    display: flex;
}

.justify-content-between {
    justify-content: space-between;
}

.align-items-center {
    align-items: center;
}

.gap-1 { gap: 10px; }
.gap-2 { gap: 20px; }

