/* ============================================================================
   GLOBAL STYLES - Professional, Modern & Compact
   ============================================================================ */

:root {
    --primary: #f18723;
    --secondary: #cc1977;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --bg: #f8f9fa;
    --card-bg: #fff;
    --text: #222;
    --text-light: #666;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --radius: 8px;
    --transition: 0.3s ease;
}

/* ============================================================================
   RESET & BASE
   ============================================================================ */

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Century Gothic", "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: margin-left var(--transition);
}

body.with-sidebar {
    margin-left: 260px;
}

body.with-sidebar.sidebar-collapsed {
    margin-left: 70px;
}

body.sidebar-collapsed {
    margin-left: 0;
}

@media (max-width: 768px) {
    body {
        margin-left: 0;
    }

    body.sidebar-collapsed {
        margin-left: 0;
    }
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    color: var(--text);
    font-weight: 600;
}

h1 {
    font-size: 1.8rem;
}

h2 {
    font-size: 1.4rem;
}

h3 {
    font-size: 1.1rem;
}

h4 {
    font-size: 1rem;
}

p {
    margin: 0.5rem 0;
    color: var(--text-light);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: #e07a1a;
}

/* ============================================================================
   FORM ELEMENTS
   ============================================================================ */

input,
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    margin: 0.5rem 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(241, 135, 35, 0.1);
}

input::placeholder {
    color: var(--text-light);
}

input:disabled,
select:disabled {
    background: var(--bg);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: #e07a1a;
    box-shadow: 0 4px 12px rgba(241, 135, 35, 0.25);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #b01567;
    box-shadow: 0 4px 12px rgba(204, 25, 119, 0.25);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 0.8rem 1.6rem;
    font-size: 1rem;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ============================================================================
   CARDS & CONTAINERS
   ============================================================================ */

.card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: all var(--transition);
    width: 100%;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

/* Login card specific styles */
.flex-center .card {
    max-width: 400px;
    margin: 0 auto;
}

.card-header {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.card-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* ============================================================================
   LAYOUT
   ============================================================================ */

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 1rem;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-start {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.grid {
    display: grid;
    gap: 1rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* ============================================================================
   DASHBOARD SPECIFIC
   ============================================================================ */

#dashboard {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
    transition: margin-left var(--transition);
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.dashboard-title {
    font-size: 1.2rem;
    color: var(--text);
    font-weight: 600;
    margin: 0;
}

.controls {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.btn-toggle {
    padding: 0.6rem 1rem;
    background: var(--text-light);
    color: white;
    font-size: 0.85rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-toggle:hover {
    background: #555;
}

.btn-toggle.active {
    background: var(--secondary);
}

.jotform-container {
    flex: 1;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    min-height: 0;
}

.jot-wrapper {
    border-radius: var(--radius);
    overflow: hidden;
    height: 100%;
}

.jot-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ============================================================================
   ALERTS & MESSAGES
   ============================================================================ */

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    animation: slideIn 0.3s ease;
}

.alert-error,
.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================================
   TABLES
   ============================================================================ */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th {
    background: var(--bg);
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text);
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

tr:hover {
    background: var(--bg);
}

/* ============================================================================
   BADGES & STATUS
   ============================================================================ */

.badge {
    display: inline-block;
    padding: 0.35rem 0.7rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-primary {
    background: rgba(241, 135, 35, 0.15);
    color: var(--primary);
}

.badge-secondary {
    background: rgba(204, 25, 119, 0.15);
    color: var(--secondary);
}

.badge-success {
    background: rgba(40, 167, 69, 0.15);
    color: var(--success);
}

.badge-danger {
    background: rgba(220, 53, 69, 0.15);
    color: var(--danger);
}

.status-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-active {
    background: rgba(40, 167, 69, 0.15);
    color: var(--success);
}

.status-inactive {
    background: rgba(220, 53, 69, 0.15);
    color: var(--danger);
}

/* ============================================================================
   UTILITIES
   ============================================================================ */

.hidden {
    display: none;
}

.invisible {
    visibility: hidden;
}

.mt-0 {
    margin-top: 0;
}

.mb-0 {
    margin-bottom: 0;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.pt-1 {
    padding-top: 0.5rem;
}

.pb-1 {
    padding-bottom: 0.5rem;
}

.pt-2 {
    padding-top: 1rem;
}

.pb-2 {
    padding-bottom: 1rem;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-light);
}

.text-primary {
    color: var(--primary);
}

.text-danger {
    color: var(--danger);
}

.text-success {
    color: var(--success);
}

.w-full {
    width: 100%;
}

.opacity-50 {
    opacity: 0.5;
}

/* ============================================================================
   MODALS
   ============================================================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 5%;
}

.modal-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    transition: color var(--transition);
}

.modal-close:hover {
    color: var(--text);
}

/* ============================================================================
   FORM LAYOUT
   ============================================================================ */

.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
    font-size: 0.95rem;
}

/* Required field asterisk styling */
.form-group label .required-asterisk,
label .required-asterisk {
    color: #dc3545;
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    margin: 0;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-row .form-group {
    margin-bottom: 0;
}

/* ============================================================================
   TABLE RESPONSIVE
   ============================================================================ */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.table-responsive table {
    margin: 0;
    width: 100%;
}

/* ============================================================================
   ROLE & STATUS BADGES
   ============================================================================ */

.role-badge {
    display: inline-block;
    padding: 0.35rem 0.7rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(241, 135, 35, 0.15);
    color: var(--primary);
}

.role-badge[title*="user"],
.role-badge[title*="User"] {
    background: rgba(23, 162, 184, 0.15);
    color: var(--info);
}

/* ============================================================================
   ACTIONS
   ============================================================================ */

.actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.actions .btn {
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
}

.btn-warning {
    background: var(--warning);
    color: #000;
}

.btn-warning:hover {
    background: #e0a800;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.25);
}

/* ============================================================================
   HEADER STYLES
   ============================================================================ */

.header {
    margin-bottom: 2rem;
    padding-bottom: 0.5rem;
}

.header h1 {
    margin: 0;
    color: var(--text);
}

/* ============================================================================
   MODAL IMPROVEMENTS
   ============================================================================ */

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--text);
}

.close {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-light);
    transition: color var(--transition);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close:hover {
    color: var(--text);
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.2rem;
    }

    .card {
        padding: 1rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .controls {
        gap: 0.3rem;
        margin: 0.75rem 0;
    }

    .btn-toggle {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
    }

    .jotform-container {
        min-height: 400px;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    table {
        font-size: 0.85rem;
    }

    td, th {
        padding: 0.5rem;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .actions {
        flex-direction: column;
    }

    .actions .btn {
        width: 100%;
    }

    .header {
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }

    .card {
        padding: 0.75rem;
    }

    .btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
    }

    h1 {
        font-size: 1.3rem;
    }

    h2 {
        font-size: 1.1rem;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
