/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #fafafa;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.btn-primary {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 8px 18px;
    border-radius: 8px;
    transition: all 0.3s;
    cursor: pointer;
    border: none;
    font-size: 14px;
    font-weight: 600;
    height: 36px;
    line-height: 20px;
}

.btn-primary:hover {
    background: #764ba2;
}

.btn-secondary {
    display: inline-block;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    padding: 8px 18px;
    border-radius: 8px;
    transition: all 0.3s;
    cursor: pointer;
    border: 1px solid rgba(102, 126, 234, 0.2);
    font-size: 14px;
    font-weight: 600;
    height: 36px;
    line-height: 20px;
}

.btn-secondary:hover {
    background: rgba(102, 126, 234, 0.15);
    border-color: #667eea;
}

.btn-secondary.disabled,
.btn-primary.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-danger {
    display: inline-block;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    padding: 8px 18px;
    border-radius: 8px;
    transition: all 0.3s;
    cursor: pointer;
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-size: 14px;
    font-weight: 600;
    height: 36px;
    line-height: 20px;
}

.btn-danger:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* Landing Page */
.landing-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.landing-header {
    background-color: #fff;
    padding: 20px;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.landing-header h1 {
    font-size: 2.5em;
    color: #007bff;
}

.landing-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.landing-content {
    text-align: center;
    max-width: 800px;
}

.landing-content h2 {
    font-size: 2em;
    margin-bottom: 20px;
}

.landing-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin: 40px 0;
}

.feature {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.feature h3 {
    font-size: 1.5em;
    margin-bottom: 10px;
}

.landing-cta {
    margin-top: 40px;
}

.landing-footer {
    background-color: #333;
    color: white;
    text-align: center;
    padding: 20px;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, #e0c3fc 0%, #8ec5fc 25%, #e0c3fc 50%, #8ec5fc 75%, #e0c3fc 100%);
    background-size: 400% 400%;
    opacity: 0.3;
    animation: gradientShift 15s ease infinite;
    filter: blur(40px);
}

.login-page::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 35px, rgba(255,255,255,.1) 35px, rgba(255,255,255,.1) 70px),
        url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="100" height="100"%3E%3Cfilter id="noise"%3E%3CfeTurbulence baseFrequency="0.9" numOctaves="4" /%3E%3C/filter%3E%3Crect width="100" height="100" filter="url(%23noise)" opacity="0.02"/%3E%3C/svg%3E');
    pointer-events: none;
    mix-blend-mode: overlay;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.login-form {
    background: rgba(255, 255, 255, 0.95);
    padding: 48px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 480px;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    position: relative;
    z-index: 1;
}

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

.login-logo p {
    color: #6b7280;
    font-size: 14px;
    margin-top: 0;
}

.login-logo h1 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2.4em;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

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

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #374151;
    letter-spacing: 0.3px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid #e5e7eb;
    border-radius: 6px;
    font-size: 15px;
    background-color: #fafbfc;
    transition: all 0.3s;
    height: 48px;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    background-color: white;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.08);
}

/* Password toggle */
.d-flex {
    display: flex;
    gap: 8px;
    align-items: center;
}

.d-flex .form-control {
    flex: 1;
}

.d-flex .btn {
    height: 48px;
    width: 48px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: #f3f4f6;
    border: 1.5px solid #e5e7eb;
    color: #6b7280;
    transition: all 0.3s;
}

.d-flex .btn:hover {
    background: #e5e7eb;
    color: #4b5563;
}

/* Login specific styles */
.login-form .alert {
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 14px;
    margin-bottom: 24px;
    border: 1px solid;
}

.login-form .text-center {
    text-align: center;
}

.login-form .text-muted {
    color: #6b7280;
}

.login-form .mt-3 {
    margin-top: 1rem;
}

.login-form small {
    font-size: 13px;
}

/* Utility classes */
.w-100 {
    width: 100%;
}

.form-checkbox {
    margin-right: 8px;
    vertical-align: middle;
}

.form-help {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

.login-form button[type="submit"] {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.1);
    margin-top: 12px;
    height: 48px;
    letter-spacing: 0.5px;
}

.login-form button[type="submit"]:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.15);
    transform: translateY(-1px);
}

/* General button styling */
button:not([type="submit"]):not(.mobile-menu-toggle) {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    height: 36px;
    line-height: 20px;
}

button:not([type="submit"]):not(.mobile-menu-toggle):hover {
    background: #764ba2;
}

/* Small button variant */
.btn-small {
    padding: 6px 14px;
    font-size: 13px;
    height: 32px;
    line-height: 20px;
    font-weight: 600;
}

/* Outline button variant */
.btn-outline-secondary {
    background: transparent;
    color: #667eea;
    padding: 8px 18px;
    border-radius: 8px;
    transition: all 0.3s;
    cursor: pointer;
    border: 1px solid #667eea;
    font-size: 14px;
    font-weight: 600;
    height: 36px;
    line-height: 20px;
}

.btn-outline-secondary:hover {
    background: rgba(102, 126, 234, 0.1);
}

/* Dashboard */
.dashboard-container {
    min-height: 100vh;
    background-color: #fafafa;
}

/* Top Bar */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(102, 126, 234, 0.08);
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.topbar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 35px, rgba(255,255,255,.05) 35px, rgba(255,255,255,.05) 70px),
        url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="100" height="100"%3E%3Cfilter id="noise"%3E%3CfeTurbulence baseFrequency="0.9" numOctaves="4" /%3E%3C/filter%3E%3Crect width="100" height="100" filter="url(%23noise)" opacity="0.02"/%3E%3C/svg%3E');
    pointer-events: none;
    mix-blend-mode: overlay;
}

.topbar-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 30px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

.topbar-brand h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.5px;
    margin: 0;
}

.topbar-brand a {
    color: white;
    text-decoration: none;
}

.topbar-nav {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
    gap: 5px;
}

.topbar-nav li {
    margin: 0;
}

.topbar-nav a {
    display: block;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.3s;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    text-decoration: none;
}

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

.topbar-nav a.active {
    background-color: #5B21B6;
    color: white;
    font-weight: 500;
}

.topbar-logout {
    margin-left: 20px;
    padding-left: 20px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px 10px;
}

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px;
    background-color: #fafafa;
}

/* Breadcrumbs */
.breadcrumbs {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 0;
    position: fixed;
    top: 60px; /* Height of topbar */
    left: 0;
    right: 0;
    z-index: 999;
}

.breadcrumbs-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 30px;
}

.breadcrumbs ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 15px 0;
    align-items: center;
    font-size: 14px;
}

.breadcrumbs li {
    display: flex;
    align-items: center;
}

.breadcrumbs li:not(:last-child)::after {
    content: '/';
    margin: 0 10px;
    color: #9ca3af;
}

.breadcrumbs a {
    color: #6b7280;
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: #5B21B6;
}

.breadcrumbs .current {
    color: #111827;
    font-weight: 500;
}

.dashboard-header {
    background: white;
    padding: 25px 30px;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: 0 0.5px 2px rgba(0,0,0,0.02);
    border: 1px solid #f0f0f0;
}

.dashboard-header h1 {
    display: inline-block;
    font-size: 28px;
    font-weight: 600;
    color: #000;
    margin: 0;
}

.header-actions {
    float: right;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Cards */
.card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0.5px 2px rgba(0,0,0,0.02);
    margin-bottom: 20px;
    border: 1px solid #f0f0f0;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f5f5f5;
}

.card-header h2,
.card-header h3 {
    color: #000;
    font-weight: 600;
    margin: 0;
}

.card-header > div {
    display: flex;
    gap: 10px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
}

/* Stats Grid for Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}


.stat-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    border: 1px solid #eee;
    text-align: center;
}

.stat-card h3 {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
    font-weight: normal;
}

.stat-number {
    font-size: 32px;
    font-weight: 600;
    color: #000;
    margin: 0;
}

/* App Cards */
.app-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 0.5px 2px rgba(0,0,0,0.02);
    border: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.2s;
}

.app-card:hover {
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    border-color: #5B21B6;
}

.app-card-icon {
    flex-shrink: 0;
}

.app-card-content {
    flex: 1;
}

.app-card-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.card-grid .card {
    margin-bottom: 0;
    transition: all 0.2s;
}

.card-grid .card:hover {
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    border-color: #5B21B6;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -5px;
    padding: 0 5px;
}

.table-responsive .table {
    min-width: 800px; /* Minimum width to prevent cramping */
}

.table th,
.table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap; /* Prevent text wrapping in cells */
}

.table td:first-child,
.table td:last-child {
    white-space: normal; /* Allow wrapping for User ID and Actions */
}

.table th {
    background-color: #fafafa;
    font-weight: 600;
    color: #000;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    color: #333;
    font-size: 14px;
}

.table tr:hover {
    background-color: #fafafa;
}

.table tbody tr[onclick],
.table tbody tr.clickable-row {
    cursor: pointer;
    transition: all 0.2s;
}

.table tbody tr[onclick]:hover,
.table tbody tr.clickable-row:hover {
    background-color: #f5f5f5;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    overflow-y: auto;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 600px;
    margin: 50px auto;
    padding: 30px;
    border-radius: 8px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid #f0f0f0;
}

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

.modal-close {
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

/* Code blocks in modals */
.modal pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: auto;
    max-width: 100%;
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
    margin: 20px 0;
}

/* Status badges */
.status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-right: 12px;
    letter-spacing: 0.5px;
}

.status.active {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.status.paused {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.status.completed {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* Weight Badge */
.weight-badge {
    display: inline-block;
    background-color: #f3f4f6;
    color: #374151;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

/* Forms */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* App search */
.search-box {
    position: relative;
    margin-bottom: 20px;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    z-index: 100;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.search-result-item:hover {
    background-color: #f8f9fa;
}

.search-result-item img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    margin-right: 10px;
}

/* App Options Grid */
.app-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.app-option-card {
    display: flex;
    align-items: center;
    padding: 24px;
    background: white;
    border: 2px solid #f3f4f6;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.app-option-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.08);
    transform: translateY(-2px);
}

.app-option-card:hover .app-option-icon {
    color: #667eea;
}

.app-option-card.disabled {
    background: #fafbfc;
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.app-option-icon {
    width: 48px;
    height: 48px;
    margin-right: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 10px;
    color: #4b5563;
    transition: all 0.3s;
}

.app-option-icon svg {
    width: 24px;
    height: 24px;
}

.app-option-content h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.app-option-content p {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
}

.app-option-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #f3f4f6;
    color: #6b7280;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Implementation Flow */
.implementation-flow {
    background: #f9fafb;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.implementation-flow ol {
    margin: 10px 0;
    padding-left: 20px;
}

.implementation-flow li {
    margin: 8px 0;
    line-height: 1.6;
}

.implementation-flow ul {
    margin: 10px 0 10px 20px;
    padding-left: 20px;
}

.implementation-flow code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.875rem;
    color: #5B21B6;
}

/* Responsive - iPad Landscape */
@media (max-width: 1024px) {
    .table th,
    .table td {
        padding: 12px 8px;
        font-size: 13px;
    }
    
    .table .btn-danger {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .badge {
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .topbar-container {
        padding: 0 15px;
    }
    
    .topbar-brand h1 {
        font-size: 18px;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .topbar-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        flex-direction: column;
        padding: 10px 0;
        box-shadow: 0 2px 4px rgba(102, 126, 234, 0.1);
        overflow: hidden;
    }
    
    .topbar-nav::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-image: 
            repeating-linear-gradient(45deg, transparent, transparent 35px, rgba(255,255,255,.05) 35px, rgba(255,255,255,.05) 70px),
            url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="100" height="100"%3E%3Cfilter id="noise"%3E%3CfeTurbulence baseFrequency="0.9" numOctaves="4" /%3E%3C/filter%3E%3Crect width="100" height="100" filter="url(%23noise)" opacity="0.02"/%3E%3C/svg%3E');
        pointer-events: none;
        mix-blend-mode: overlay;
    }
    
    .topbar-nav.show {
        display: flex;
    }
    
    .topbar-nav li {
        width: 100%;
        position: relative;
        z-index: 1;
    }
    
    .topbar-nav a {
        padding: 12px 20px;
        font-size: 14px;
        border-radius: 0;
    }
    
    .topbar-logout {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
        margin-top: 10px;
        padding-top: 10px;
    }
    
    .main-content {
        padding: 20px 15px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .card-grid {
        grid-template-columns: 1fr;
    }
    
    .app-options-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .app-option-card {
        padding: 20px;
    }
    
    .app-option-icon {
        width: 40px;
        height: 40px;
        margin-right: 16px;
    }
}