/* styles.css */
:root {
    --primary-color: #e71029;
    --primary-hover-color: #bd0a27;
    --gradient-start-color: #fe2d3c;
    --gradient-end-color: #fe605d;
    --error-color: #de350b;
    --error-background-color: #ffbdad;
    --background-color: #f4f5f7;
    --form-background-color: #ffffff;
    --text-color: #172b4d;
    --subtle-text-color: #5e6c84;
    --border-color: #dfe1e6;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    color: var(--text-color);
}

.main-container {
    display: flex;
    width: 100%;
    max-width: 1200px;
    min-height: 600px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
    margin: 20px;
}

.branding-section {
    background: linear-gradient(135deg, var(--gradient-start-color), var(--gradient-end-color));
    color: white;
    padding: 60px 40px;
    width: 45%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.branding-section .logo {
    max-width: 180px;
    height: auto;
    margin-bottom: 25px;
}

.branding-section h1 {
    font-size: 1.8em;
    font-weight: 600;
    margin-bottom: 15px;
}

.branding-section p {
    font-size: 1em;
    max-width: 300px;
    line-height: 1.6;
    opacity: 0.9;
}

.login-section {
    background-color: var(--form-background-color);
    padding: 40px 60px;
    width: 55%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

h2 {
    color: var(--text-color);
    margin-bottom: 10px;
    font-size: 2em;
    font-weight: 700;
}

.subtitle {
    color: var(--subtle-text-color);
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.9em;
}

.input-wrapper {
    position: relative;
}

.input-wrapper .icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--subtle-text-color);
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="tel"],
select {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 1em;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background-color: #fafbfc;
    font-family: 'Inter', sans-serif;
}

select {
    padding: 12px 15px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
}

input:focus, select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(231, 16, 41, 0.25);
    background-color: #fff;
}

/* Specific padding for inputs without an icon */
/* FIX: Removed input#org_name from this list to ensure it gets the 45px left padding for its icon. */
select, input#country { 
    padding-left: 15px;
}

.login-button {
    width: auto;
    min-width: 150px;
    padding: 15px 25px;
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    margin-top: 10px;
}

.login-button:hover {
    background-color: var(--primary-hover-color);
    transform: translateY(-2px);
}

.signup-link {
    text-align: center;
    margin-top: 25px;
    font-size: 0.95em;
    color: var(--subtle-text-color);
}

.signup-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.signup-link a:hover {
    text-decoration: underline;
}

.php-error-message, .error-message {
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    color: var(--error-color);
    background-color: var(--error-background-color);
    border: 1px solid var(--error-color);
}

.error-message {
    background: none;
    border: none;
    text-align: left;
    padding: 0;
    margin-top: 5px;
    min-height: 1.2em;
    font-size: 0.85em;
}

@media (max-width: 992px) {
    .main-container {
        flex-direction: column;
        min-height: auto;
        width: 100%;
        max-width: 500px;
    }
    .branding-section {
        display: none; /* Hide branding on smaller screens for focus */
    }
    .login-section {
        width: 100%;
        padding: 40px;
    }
}


/* --- NEW STYLES TO BE ADDED FOR ESS PORTAL --- */

/* General Purpose Container */
.container {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
}
@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }
}
@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
}
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

/* Card Style for Content */
.card {
    background-color: var(--form-background-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
    overflow: hidden;
}

.card-header, .card-body, .card-footer {
    padding: 1.5rem;
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    background-color: #fafbfc;
}

.card-title {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
}

/* Flexbox Utilities */
.d-flex {
    display: flex !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

.align-items-center {
    align-items: center !important;
}

/* Secondary Button Style */
.btn {
    display: inline-block;
    font-weight: 600;
    color: #212529;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: 8px;
    transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}

.btn-secondary {
    color: var(--text-color);
    background-color: #e9ecef;
    border-color: #e9ecef;
}

.btn-secondary:hover {
    background-color: #d3d9df;
    border-color: #c7ced5;
}

/* Text Utilities */
.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right !important;
}

.text-muted {
    color: var(--subtle-text-color) !important;
}

/* --- NEW STYLES TO BE ADDED FOR ESS PORTAL --- */

/* General Purpose Container */
.container {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
}
@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }
}
@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
}
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

/* Card Style for Content */
.card {
    background-color: var(--form-background-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
    overflow: hidden;
}

.card-header, .card-body, .card-footer {
    padding: 1.5rem;
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    background-color: #fafbfc;
}

.card-title {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
}

/* Flexbox Utilities */
.d-flex {
    display: flex !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

.align-items-center {
    align-items: center !important;
}

/* Secondary Button Style */
.btn {
    display: inline-block;
    font-weight: 600;
    color: #212529;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: 8px;
    transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}

.btn-secondary {
    color: var(--text-color);
    background-color: #e9ecef;
    border-color: #e9ecef;
}

.btn-secondary:hover {
    background-color: #d3d9df;
    border-color: #c7ced5;
}

/* Text Utilities */
.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right !important;
}

.text-muted {
    color: var(--subtle-text-color) !important;
}

/* Table Styles */
.table {
    width: 100%;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.table th,
.table td {
    padding: 0.75rem;
    vertical-align: top;
    border-top: 1px solid var(--border-color);
}

.table thead th {
    vertical-align: bottom;
    border-bottom: 2px solid var(--border-color);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0,0,0,.05);
}

.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Badge Styles */
.badge {
    display: inline-block;
    padding: .25em .4em;
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: .25rem;
    transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}

.badge-pending {
    color: #856404;
    background-color: #fff3cd;
}

.badge-approved {
    color: #155724;
    background-color: #d4edda;
}

.badge-rejected {
    color: #721c24;
    background-color: #f8d7da;
}

/* Form Control full width */
.form-control {
    display: block;
    width: 100%;
    height: calc(1.5em + .75rem + 2px);
    padding: .375rem .75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: .25rem;
    transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}

textarea.form-control {
    height: auto;
}

/* --- NEW STYLES FOR ESS PORTAL LAYOUT --- */

/* Main container for the entire portal page */
.ess-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    background-color: var(--background-color);
}

/* Sidebar Styles */
.ess-sidebar {
    width: 260px;
    background-color: var(--form-background-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
    transition: width 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
    padding: 0 10px;
}

.sidebar-header .logo {
    width: 40px;
    height: 40px;
    margin-right: 15px;
}

.sidebar-header .sidebar-title {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--text-color);
}

/* Navigation Links */
.ess-nav {
    flex-grow: 1;
}

.ess-nav a {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    margin-bottom: 8px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--subtle-text-color);
    font-weight: 600;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.ess-nav a .fa-fw {
    width: 1.25em; /* Fixed width for icons */
    margin-right: 15px;
    font-size: 1.1em;
}

.ess-nav a:hover {
    background-color: #f0f0f0;
    color: var(--text-color);
}

.ess-nav a.active {
    background-color: var(--primary-color);
    color: #fff;
}

/* Sidebar Footer for Logout */
.sidebar-footer {
    margin-top: auto;
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--subtle-text-color);
    font-weight: 600;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.sidebar-footer a:hover {
    background-color: #f0f0f0;
    color: var(--text-color);
}

/* Main Content Area */
.ess-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

/* Header inside Main Content */
.ess-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    background-color: var(--form-background-color);
    border-bottom: 1px solid var(--border-color);
}

.ess-header-title {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
}

.user-info span {
    font-weight: 500;
}

/* The actual area for cards and forms */
.content-area {
    padding: 40px;
    flex-grow: 1;
}

/* Alert Boxes */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: .25rem;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .ess-sidebar {
        width: 70px;
    }
    .ess-sidebar .sidebar-title,
    .ess-nav span,
    .sidebar-footer span {
        display: none;
    }
    .ess-nav a, .sidebar-footer a {
        justify-content: center;
    }
     .ess-nav a .fa-fw, .sidebar-footer a .fa-fw {
        margin-right: 0;
    }
    .ess-header {
        padding: 15px 20px;
    }
    .content-area {
        padding: 20px;
    }
}

/* --- STYLES FOR CORPORATE HEADER & FOOTER --- */

/* Main wrapper to help with footer placement */
.main-wrapper {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 70px - 60px); /* Full height minus header and footer height */
}

/* Corporate Header */
.corp-header {
    background-color: var(--form-background-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0 40px;
    height: 70px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.corp-header-content {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-between;
}

.corp-logo {
    display: flex;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
}

.corp-logo img {
    height: 40px;
    margin-right: 12px;
}

.corp-nav {
    display: flex;
    gap: 10px;
}

.corp-nav .nav-item {
    padding: 10px 15px;
    text-decoration: none;
    color: var(--subtle-text-color);
    font-weight: 600;
    border-radius: 8px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.corp-nav .nav-item:hover {
    background-color: #f0f0f0;
    color: var(--text-color);
}

/* User Menu Dropdown */
.user-menu {
    position: relative;
}

.user-menu-button {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 1em;
    font-weight: 500;
}

.user-menu-button i.fa-user-circle {
    font-size: 1.8em;
    color: var(--primary-color);
}
.user-menu-button i.fa-chevron-down {
    font-size: 0.8em;
    color: var(--subtle-text-color);
}

.user-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 120%;
    background-color: var(--form-background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 180px;
    overflow: hidden;
}

.user-menu:hover .user-menu-dropdown {
    display: block;
}

.user-menu-dropdown a {
    display: block;
    padding: 12px 15px;
    text-decoration: none;
    color: var(--text-color);
}

.user-menu-dropdown a:hover {
    background-color: #f0f0f0;
}


/* Corporate Footer */
.corp-footer {
    background-color: #344054; /* A corporate dark color */
    color: #eaecf0;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    font-size: 0.9em;
}

.corp-footer .footer-links a {
    color: #eaecf0;
    text-decoration: none;
    margin-left: 20px;
}

.corp-footer .footer-links a:hover {
    text-decoration: underline;
}

/* Ensure body has no margin */
body {
    margin: 0; 
}

/* --- START: Added Responsive Styles for All Devices --- */

/* 992px (Tablets) - Header adjustments */
@media (max-width: 992px) {
    .corp-header {
        padding: 0 20px; /* Reduce side padding */
    }
    .corp-nav .nav-item {
        padding: 10px 12px; /* Tighten nav links */
    }
    
    /* Fix for existing 992px query on login box */
    .main-container {
        max-width: 500px;
    }
    .branding-section {
        display: none;
    }
    .login-section {
        width: 100%;
    }
}

/* 768px (Small Tablets / Large Phones) - Major layout changes */
@media (max-width: 768px) {
    /* Signup Modal */
    .modal-content {
        max-width: 90vw; /* Make modal fluid */
        padding: 25px;
    }
    .modal-grid {
        grid-template-columns: 1fr; /* Stack modal form fields */
        gap: 15px 0;
    }

    /* Corporate Header */
    .corp-nav {
        display: none; /* Hide text-based nav on mobile */
    }
    .user-menu-button span {
        display: none; /* Hide user name, show only icon */
    }
    .user-menu-button i.fa-user-circle {
        font-size: 1.6em; /* Slightly smaller icon */
    }

    /* Corporate Footer */
    .corp-footer {
        flex-direction: column; /* Stack footer content */
        height: auto;
        padding: 20px 15px;
        gap: 15px;
        text-align: center;
    }
    .corp-footer .footer-links {
        display: flex;
        flex-direction: column; /* Stack footer links */
        align-items: center;
        gap: 10px;
    }
    .corp-footer .footer-links a {
        margin-left: 0; /* Remove side margin */
    }

    /* Main ESS Header (from your other styles) */
    .ess-header {
        flex-direction: column; /* Stack title and user info */
        align-items: flex-start;
        gap: 10px;
    }
    .ess-header-title {
        font-size: 1.5em; /* Reduce title size */
    }

    /* General Typography & Login Form */
    h2 {
        font-size: 1.8em;
    }
    .login-section {
        padding: 40px 30px; /* Reduce padding on login form */
    }
}

/* 576px (Small Phones) - Full-screen elements */
@media (max-width: 576px) {
    /* Make login form full-screen on small devices */
    .main-container {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
        box-shadow: none;
    }
    .login-section {
        padding: 30px 25px; /* Adjust padding for small screens */
    }

    /* Make modal full-screen on small devices */
    .modal-content {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        padding: 20px;
        border-radius: 0;
        overflow-y: auto; /* Ensure modal content can scroll */
    }

    /* Corporate Header */
    .corp-header {
        padding: 0 15px; /* Further reduce padding */
    }
    .corp-logo span {
        display: none; /* Hide logo text, show only image */
    }
    .corp-logo img {
        height: 35px; /* Adjust logo image size */
    }

    /* General Typography */
    h2 {
        font-size: 1.6em;
    }
    .subtitle {
        margin-bottom: 20px;
    }
}

/* --- END: Added Responsive Styles --- */

/* --- START: Added Modal Styles from Signup Page.php --- */

/* Styles for the modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(5px);
    display: none; justify-content: center; align-items: center;
    z-index: 1000;
}
.modal-overlay.active { display: flex; }
.modal-content {
    width: 100%; max-width: 600px; padding: 30px 40px;
    background: var(--form-background-color); border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    text-align: left; color: var(--text-color);
    max-height: 90vh;
    overflow-y: auto;
}
.modal-content h2 { text-align: center; font-weight: 700; margin-bottom: 5px; }
.modal-content p { text-align: center; font-size: 0.9em; color: var(--subtle-text-color); margin-bottom: 20px; }
.modal-content label { font-size: 0.9em; font-weight: 600; }

.modal-content .form-group { margin-bottom: 15px; }
.modal-content .input-wrapper .icon { display: none; }

/* * !! --- THIS IS THE CRITICAL FIX --- !!
 * It resets the padding for inputs INSIDE the modal
 * to the normal 12px 15px, removing the 45px icon padding.
 */
.modal-content input[type="email"],
.modal-content input[type="password"],
.modal-content input[type="text"],
.modal-content input[type="tel"],
.modal-content select {
    padding: 12px 15px;
}

/* File input styling */
.file-input-label {
    display: inline-block; cursor: pointer; padding: 10px 15px;
    background-color: #f0f0f0; border-radius: 6px;
    transition: background-color 0.3s;
    font-weight: 500;
    border: 1px solid var(--border-color);
}
.file-input-label:hover { background-color: #e0e0e0; }
#logo-filename { margin-left: 10px; font-style: italic; opacity: 0.7; font-size: 0.9em; }

/* Grid layout for modal */
.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px 30px;
}

.modal-grid .full-width {
    grid-column: 1 / -1;
}

/* --- END: Added Modal Styles --- */