/* =========================================================================
   Laravel SaaS Dashboard Theme Styles
   Colors: White, Light Gray, Primary Blue
========================================================================= */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f3f4f6;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;

    --success: #10b981;
    --success-bg: #d1fae5;
    --success-text: #065f46;

    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;

    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;

    --font-family: 'Inter', sans-serif;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --border-radius: 0.5rem;
    --transition: all 0.2s ease-in-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: var(--primary);
    transition: var(--transition);
}

a:hover {
    text-decoration: underline;
}

/* =========================================================================
   Layout
========================================================================= */

#sidebar {
    width: 250px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 50;
    transition: transform 0.3s ease-in-out;
}

.sidebar-brand {
    padding: 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-brand a {
    text-decoration: none;
    color: var(--primary);
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-muted);
    font-weight: 500;
    gap: 0.75rem;
    transition: var(--transition);
    text-decoration: none;
}

.nav-item:hover,
.nav-item.active {
    background-color: #f8fafc;
    color: var(--primary);
    border-right: 3px solid var(--primary);
    text-decoration: none;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--danger);
    font-size: 0.875rem;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 100%;
}

#main-content {
    flex: 1;
    margin-left: 250px;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease-in-out;
}

.top-header {
    height: 64px;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 5;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.main-container {
    padding: 2rem;
    flex: 1;
}

/* =========================================================================
   Components
========================================================================= */

.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-title {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue {
    background-color: #dbeafe;
    color: var(--primary);
}

.stat-icon.green {
    background-color: var(--success-bg);
    color: var(--success);
}

.stat-icon.yellow {
    background-color: var(--warning-bg);
    color: var(--warning);
}

.stat-icon.red {
    background-color: var(--danger-bg);
    color: var(--danger);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    color: white;
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--bg-color);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: var(--danger-text);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background-color: #f9fafb;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.05em;
}

.table td {
    font-size: 0.875rem;
    vertical-align: middle;
}

.table tr:hover {
    background-color: #f9fafb;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background-color: var(--success-bg);
    color: var(--success-text);
}

.badge-warning {
    background-color: var(--warning-bg);
    color: var(--warning-text);
}

.badge-danger {
    background-color: var(--danger-bg);
    color: var(--danger-text);
}

.badge-gray {
    background-color: #f3f4f6;
    color: #4b5563;
}

/* Companies Grid */
.company-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.company-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
}

.company-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.company-card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.company-name {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.company-card-body {
    padding: 1.5rem;
    flex: 1;
}

.company-detail-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.company-card-footer {
    padding: 1rem 1.5rem;
    background-color: #f9fafb;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.invalid-feedback {
    display: block;
    color: var(--danger);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Utilities */
.text-muted {
    color: var(--text-muted);
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.d-flex {
    display: flex;
}

.justify-content-between {
    justify-content: space-between;
}

.align-items-center {
    align-items: center;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 0.75rem;
}

.w-100 {
    width: 100%;
}

.text-danger {
    color: var(--danger);
}

.alert {
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.alert-success {
    background-color: var(--success-bg);
    color: var(--success-text);
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background-color: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid #fecaca;
}

/* Login */
.login-body {
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary);
}

.login-logo i {
    font-size: 3rem;
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 0.5rem;
    color: var(--text-main);
}

/* Mobile Responsiveness */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 1rem;
    border-radius: var(--border-radius);
}

.mobile-menu-btn:hover {
    background-color: var(--border-color);
}

/* Overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

body.sidebar-open .sidebar-overlay {
    opacity: 1;
}

@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-open #sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    #main-content {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: block;
    }

    .top-header {
        padding: 0 1rem;
    }

    .user-info {
        display: none !important;
    }

    /* Stacked Form and Headers for Mobile */
    .d-flex.justify-content-between.align-items-center {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .d-flex.justify-content-between.align-items-center>div {
        width: 100%;
        justify-content: space-between;
    }

    form.d-flex {
        width: 100%;
    }

    form.d-flex input[type="text"] {
        flex: 1;
        width: auto !important;
    }

    /* Responsive Tables as Cards */
    .table-responsive {
        border: none;
    }

    .table thead {
        display: none;
    }

    .table,
    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
    }

    .table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        padding: 0.5rem;
    }

    .table td {
        text-align: right;
        padding: 0.75rem 1rem 0.75rem 45%;
        position: relative;
        border-bottom: 1px solid #f3f4f6;
        min-height: 3rem;
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }

    .table td:last-child {
        border-bottom: none;
    }

    .table td::before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        width: 40%;
        text-align: left;
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.75rem;
        text-transform: uppercase;
        display: flex;
        align-items: center;
        height: 100%;
        top: 0;
    }

    .table td>div {
        justify-content: flex-end;
    }
}