/* Reset and Base Styles */
:root {
    /* Match logo color */
    --vivacare-primary: #005F6A;
    --vivacare-primary-dark: #004a53;
    --vivacare-primary-light: #0a7a86;
}

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

body {
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    line-height: 1.7;
    color: #0f172a;
    background-color: #f1f5f9;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* Standard Button Styles - Based on tider page design */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    line-height: 1.4;
    gap: 6px;
}

.btn-primary {
    background-color: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.btn-primary:hover {
    background-color: #2563eb;
    border-color: #2563eb;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
    border-color: #6b7280;
}

.btn-secondary:hover {
    background-color: #4b5563;
    border-color: #4b5563;
}

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

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

/* Button sizes */
.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

/* Button variants for specific use cases */
.btn-success {
    background-color: #10b981;
    color: white;
    border-color: #10b981;
}

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

.btn-warning {
    background-color: #f59e0b;
    color: white;
    border-color: #f59e0b;
}

.btn-warning:hover {
    background-color: #d97706;
    border-color: #d97706;
}

/* Active state for punch in (timer running) */
.btn-primary.punched-in {
    background: #ef4444; /* red */
    border-color: #ef4444;
}

.btn-primary.punched-in:hover {
    background: #dc2626;
    border-color: #dc2626;
}

/* Round button styles from schema.css */
.btn-round {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
}

.btn-round:hover {
    background: #f3f4f6;
}

/* Action buttons for dashboard */
.action-btn {
    background: #ffffff;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #1f2937;
}

/* Form action buttons */
.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.form-actions-left {
    display: flex;
    gap: 0.5rem;
}

.form-actions-right {
    display: flex;
    gap: 0.5rem;
}

/* Accept/Neka button styles */
.accept-btn {
    background-color: #10b981;
    color: white;
    border: 1px solid #10b981;
}

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

.neka-btn {
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.neka-btn:hover {
    background-color: #e5e7eb;
    border-color: #9ca3af;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Quick time buttons (from tider modal) */
.quick-time-btn {
    font-size: 10px;
    padding: 3px 6px;
    flex: 0 0 auto;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
}

/* Card action buttons */
.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Toolbar buttons */
.schema-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Logout button */
.logout-btn {
    background: #dc3545;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: #c82333;
}

/* Main content area */
main {
    margin: 0;
    padding: 2rem 1rem;
    min-height: calc(100vh - 64px);
}

/* Dashboard Styles */
.dashboard-main {
    min-height: calc(100vh - 140px);
    padding: 0;
    background: var(--bg-secondary);
}

.dashboard-container {
    margin: 0;
    padding: 0;
}

/* Shared page header for dashboard, tider, users, arbetsplatser */
.page-header {
    max-width: 1400px;
    margin: 0 auto 24px auto;
    padding: 0 24px;
}

/* Two-column layout for dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.dashboard-left,
.dashboard-right {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Message Card */
.message-card {
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin: 0 0 20px 0;
    transition: box-shadow 0.2s ease;
    width: 100%;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.message-card:hover {
    transform: none;
    box-shadow: 0 1px 2px var(--shadow-light);
}

.message-content {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    gap: 30px;
}

/* Avatar placeholder for messages */
.message-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    font-weight: 600;
    flex-shrink: 0;
    text-transform: uppercase;
}

.message-avatar i {
    font-size: 20px;
}

/* User avatar in navbar */
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    cursor: pointer;
}

/* Dashboard avatar section */
.user-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.user-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 2rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 3px solid #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.user-avatar-large:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.user-avatar-large img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
    text-align: center;
}

/* Message card header styling */
.message-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
}

.message-card .card-title h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.message-card .card-actions {
    display: flex;
    gap: 8px;
}

.message-card .card-content {
    padding: 0;
}

/* Tider and Users page card styling (same as dashboard) */
.tider-card,
.users-card {
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin: 0 0 20px 0;
    width: 100%;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

/* Dashboard specific cards with max-width */
#mina-tider-card {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.tider-card .card-header,
.users-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
}

.tider-card .card-title h2,
.users-card .card-title h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.tider-card .card-actions,
.users-card .card-actions {
    display: flex;
    gap: 8px;
}

.tider-card .card-content,
.users-card .card-content {
    padding: 0;
}

.tider-card .table-container,
.users-card .table-container {
    overflow-x: auto;
}

/* Table styling for ALL tables - tider, users, and dashboard mina-tider */
#tider-table,
#users-table,
#arbetsplatser-table,
#mina-tider-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto; /* Allow columns to size based on content, except Notis which will expand */
}

/* Make Notis column expand to fill available space */
#tider-table th:nth-child(6),
#tider-table td:nth-child(6),
#mina-tider-table th:nth-child(4),
#mina-tider-table td:nth-child(4) {
    width: auto;
    min-width: 100px; /* Minimum width for readability */
}

/* Prevent Skapad column from wrapping - same as tider table */
#mina-tider-table th:nth-child(6),
#mina-tider-table td:nth-child(6) {
    white-space: nowrap;
}

#tider-table thead th,
#users-table thead th,
#arbetsplatser-table thead th,
#mina-tider-table thead th {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    text-align: left;
    font-weight: 600;
    background: #f8fafc;
    font-size: 14px;
    min-width: 100px; /* Minimum width for readability */
}

#tider-table tbody td,
#users-table tbody td,
#arbetsplatser-table tbody td,
#mina-tider-table tbody td {
    padding: 4px 8px;
    border: 1px solid #e5e7eb;
    vertical-align: middle;
    font-size: 14px;
    height: 32px;
    min-width: 100px; /* Minimum width for readability */
}

/* Prevent date/time columns from wrapping on desktop - Start and Slut columns */
#tider-table tbody td:nth-child(3),
#tider-table tbody td:nth-child(4),
#mina-tider-table tbody td:nth-child(2),
#mina-tider-table tbody td:nth-child(3) {
    white-space: nowrap;
}

#tider-table tbody tr,
#users-table tbody tr,
#arbetsplatser-table tbody tr,
#mina-tider-table tbody tr {
    height: 32px;
}

/* Global Table Button Classes - Match Dashboard Mina Tider Buttons Exactly */
.table-accept {
    background-color: #3b82f6;
    color: white;
    border: 1px solid #3b82f6;
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s;
    font-weight: 500;
    flex: 1;
}

.table-accept:hover {
    background-color: #2563eb;
    border-color: #2563eb;
}

.table-neka {
    background-color: #6b7280;
    color: white;
    border: 1px solid #6b7280;
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s;
    font-weight: 500;
    flex: 1;
}

.table-neka:hover {
    background-color: #4b5563;
    border-color: #4b5563;
}

.table-delete {
    background-color: #f87171;
    color: white;
    border: 1px solid #f87171;
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s;
    font-weight: 500;
    flex: 1;
}

.table-delete:hover {
    background-color: #ef4444;
    border-color: #ef4444;
}

/* Edit button should be blue, not red */
.table-delete[data-action="edit"] {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

.table-delete[data-action="edit"]:hover {
    background-color: #2563eb;
    border-color: #2563eb;
}

/* Container styling for full width */
.tider-container,
.users-container {
    width: 100%;
    margin: 0;
    padding: 0;
}

.tider-main,
.users-main {
    padding: 10px;
    margin: 0;
    width: 100%;
}

.message-text {
    flex: 1;
}

.message-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.message-loading i {
    font-size: 2rem;
    margin-bottom: 15px;
    color: var(--vivacare-primary);
}

.meddelande-item {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
    position: relative;
}

.meddelande-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* Message separator line */
.meddelande-item:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background-color: #e5e7eb;
}

.meddelande-text {
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 8px;
}

.meddelande-date {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.meddelanden-empty {
    text-align: left;
    padding: 40px 20px;
    color: var(--text-muted);
}

.meddelanden-empty i {
    font-size: 2rem;
    margin-bottom: 15px;
    color: var(--vivacare-primary);
    opacity: 0.5;
}

.meddelanden-empty p {
    font-size: 1rem;
    margin: 0;
}

/* Container and Card Styles */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Cards and containers */
.card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    transition: all 0.2s ease;
}

/* Card Header and Body */
.card-header {
    display: none;
}

.card-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 25px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.info-item:last-child {
    margin-bottom: 0;
}

.info-item span {
    color: var(--text-secondary);
}

.card:hover {
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
}

/* Form elements */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #0f172a;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: #ffffff;
    color: #0f172a;
}

.form-input:focus {
    outline: none;
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.table th {
    background: #f1f5f9;
    font-weight: 600;
    color: #0f172a;
}

.table tr:hover {
    background: #f1f5f9;
}

/* Responsive design */
@media (max-width: 768px) {
    
    main {
        padding: 0 !important;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    .btn-round {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .card {
        padding: 1rem;
    }
    
    /* Mobile: Make cards go full width on dashboard, tider, anställda pages */
    .dashboard-container,
    .tider-container,
    .users-container {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }
    
    .message-card,
    #mina-tider-card,
    .card,
    .tider-card,
    .users-card {
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 0 !important;
        width: 100% !important;
        max-width: none !important;
    }
    
    /* Ensure body and html have no padding on mobile */
    body, html {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Remove any container padding */
    .container {
        padding: 0 !important;
        margin: 0 !important;
        max-width: none !important;
    }
    
    /* Ensure tider table is visible on mobile */
    .tider-card {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        margin: 16px !important;
        width: calc(100% - 32px) !important;
    }
    
    .tider-card .card-header {
        display: flex !important;
        padding: 12px 16px !important;
    }
    
    .tider-card .card-content {
        padding: 0 16px 16px 16px !important;
    }
    
    .tider-card .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    #tider-table,
    #mina-tider-table {
        min-width: 600px !important;
    }
    
    #tider-table th,
    #tider-table td,
    #mina-tider-table th,
    #mina-tider-table td {
        padding: 8px 6px !important;
        font-size: 12px !important;
    }
    
    /* Ensure dashboard mina-tider table matches tider table styling on mobile */
    #mina-tider-card {
        margin: 16px !important;
        width: calc(100% - 32px) !important;
    }
    
    #mina-tider-card .card-content {
        padding: 0 16px 16px 16px !important;
    }
    
    #mina-tider-card .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* Cancel button style - based on "Avbryt" button */
.cancel-btn {
    background-color: #f1f3f4;
    color: #5f6368;
    border: 1px solid #dadce0;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
    min-height: 36px;
}

.cancel-btn:hover {
    background-color: #e8eaed;
    border-color: #bdc1c6;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.cancel-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cancel-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

/* Cancel button with icon */
.cancel-btn i {
    font-size: 14px;
}

/* Small cancel button */
.cancel-btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    min-height: 28px;
}

/* Large cancel button */
.cancel-btn-lg {
    padding: 12px 24px;
    font-size: 16px;
    min-height: 44px;
}

/* Modal blur effect when ny tider modal is active */
body.modal-active {
    overflow: hidden;
}

/* IMPORTANT:
   Avoid expensive blur filters on the entire page when modals are open.
   We rely on the modal overlay (rgba background) to "inactive" the page instead. */

/* Filter button active state fix */
.filter-btn {
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 12px;
    display: inline-block;
}

/* Active state - blue background */
.filter-btn.active {
    background-color: #3b82f6 !important;
    color: white !important;
    border: none !important;
}

/* Inactive state - gray background */
.filter-btn:not(.active) {
    background-color: #f3f4f6 !important;
    color: #374151 !important;
    border: none !important;
}

/* Hover state for inactive buttons */
.filter-btn:hover:not(.active) {
    background-color: #e5e7eb !important;
}

/* Ensure no inline styles override - Dashboard specific */
#mina-tider-filter .filter-btn {
    background-color: #f3f4f6 !important;
    color: #374151 !important;
    border: none !important;
    padding: 4px 8px !important;
    font-size: 12px !important;
    transition: all 0.2s ease !important;
}

#mina-tider-filter .filter-btn.active {
    background-color: #3b82f6 !important;
    color: white !important;
    border: none !important;
}

/* Force override any conflicting styles */
#mina-tider-filter button.filter-btn {
    background-color: #f3f4f6 !important;
    color: #374151 !important;
}

#mina-tider-filter button.filter-btn.active {
    background-color: #3b82f6 !important;
    color: white !important;
}

/* Tider page filter buttons - same styling as dashboard */
#tider-filter .filter-btn {
    background-color: #f3f4f6 !important;
    color: #374151 !important;
    border: none !important;
    padding: 4px 8px !important;
    font-size: 12px !important;
    transition: all 0.2s ease !important;
}

#tider-filter .filter-btn.active {
    background-color: #3b82f6 !important;
    color: white !important;
    border: none !important;
}

#tider-filter button.filter-btn {
    background-color: #f3f4f6 !important;
    color: #374151 !important;
}

#tider-filter button.filter-btn.active {
    background-color: #3b82f6 !important;
    color: white !important;
}

/* Force override for dashboard - even more specific */
#mina-tider-filter button.filter-btn.active {
    background-color: #3b82f6 !important;
    color: white !important;
    background: #3b82f6 !important;
}

#mina-tider-filter button.filter-btn:not(.active) {
    background-color: #f3f4f6 !important;
    color: #374151 !important;
    background: #f3f4f6 !important;
}
