/* assets/css/views/mayday.css */

/* 
   MAYDAY ULTIMATE BREAK-OUT LAYOUT
   Bypasses parent containers to fill the screen exactly.
*/

.mayday-v2.dashboard-layout {
    position: fixed !important;
    top: 45px !important;
    /* Navbar height */
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 10 !important;
    /* Under dropdowns but over main content */

    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;

    width: 100vw !important;
    height: calc(100vh - 45px) !important;

    box-sizing: border-box !important;
    padding: 15px !important;
    gap: 15px !important;
    background: var(--bg-body);

    margin: 0 !important;
}

/* Ensure parents don't clip this */
#app,
.app-container {
    overflow-x: hidden;
}

/* Sidebars - Forced Stretch */
.mayday-v2 .dashboard-sidebar {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    flex: 0 0 280px !important;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.sidebar-header-custom {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

.sidebar-scroll {
    flex: 1 !important;
    overflow-y: auto;
    padding: 10px;
}

/* Navigation Items */
.nav-section {
    margin-bottom: 20px;
}

.section-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 0 10px 8px;
    opacity: 0.6;
}

.nav-item-v2 {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all 0.2s;
}

.nav-item-v2:hover {
    background: rgba(59, 130, 246, 0.08);
}

.nav-item-v2.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    font-weight: 700;
}

/* Main Content: Mayday Iframe Container */
.mayday-main-v2 {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden !important;
    height: 100% !important;
}

.full-iframe {
    width: 100% !important;
    height: 100% !important;
    flex: 1 !important;
    border: none !important;
    background: white !important;
}

.iframe-placeholder {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Respect the impersonation banner if it exists */
.impersonating .mayday-v2.dashboard-layout {
    top: 85px !important;
    height: calc(100vh - 85px) !important;
}

/* Admin Controls */
.admin-actions {
    padding: 10px 15px;
    display: flex;
    justify-content: flex-end;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.btn-admin-manage {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-admin-manage:hover {
    background: var(--primary);
    color: white;
}

/* Management Modal Styles */
.mayday-mgmt-modal {
    width: 95%;
    max-width: 1000px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-xl);
}

.modal-header-premium {
    padding: 20px 24px;
    background: var(--primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header-premium h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.btn-close-modal {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-close-modal:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.mgmt-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 0;
    /* Allow flex shrinking for scrolling */
}

/* Icon Picker Styles */
.picker-container {
    position: relative;
}

.icon-selector-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.icon-selector-trigger:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.icon-selector-trigger i:first-child {
    font-size: 1.2rem;
    color: var(--primary);
}

.icon-selector-trigger i:last-child {
    margin-left: auto;
    color: var(--text-muted);
}

.icon-picker-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    padding: 12px;
    margin-top: 5px;
}

.icon-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.2rem;
}

.icon-option:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.icon-option.selected {
    background: var(--primary);
    color: white;
}

/* Drag & Drop */
.drag-handle-cell {
    width: 40px;
    text-align: center;
}

.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: color 0.2s;
}

.drag-handle:hover {
    color: var(--primary);
}

.mgmt-row.sortable-ghost {
    opacity: 0.4;
    background: var(--primary-light) !important;
}

.mgmt-row.sortable-chosen {
    background: var(--bg-hover) !important;
}

/* One-line table refinements */
.mgmt-table td {
    white-space: nowrap;
}

.id-trunc {
    display: block;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.flex-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.item-icon-preview {
    font-size: 1.1rem;
    color: var(--primary);
    width: 20px;
    text-align: center;
}

.mgmt-form-grid-premium {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row-structure {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    align-items: flex-end;
}

.form-group-v2 select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M12 16L6 10H18L12 16Z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
}

.form-group-v2 select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.mt-4 {
    margin-top: 1.5rem !important;
}

.mgmt-table-wrapper {
    background: var(--bg-body);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.mgmt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.mgmt-table th {
    background: var(--bg-body-secondary);
    padding: 12px 16px;
    text-align: left;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
}

.mgmt-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

.mgmt-table tr:hover {
    background: var(--bg-hover);
}

.mgmt-table tr:last-child td {
    border-bottom: none;
}

.badge-section {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-fixe {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.badge-mobile {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.actions-cell {
    display: flex;
    gap: 8px;
}

.btn-icon-action {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
}

.btn-icon-action.edit:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-icon-action.delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: #ef4444;
}

/* Add/Edit Form */
.mgmt-form-card {
    background: var(--bg-body);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.mgmt-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.form-group-v2 {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group-v2 label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
}

.form-group-v2 input,
.form-group-v2 select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 0.85rem;
}

.form-group-v2 input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-light);
}

.form-actions-v2 {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-premium {
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-premium.primary {
    background: var(--primary);
    color: white;
}

.btn-premium.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-premium.secondary {
    background: var(--bg-body-secondary);
    color: var(--text-main);
}

.btn-premium.secondary:hover {
    background: var(--bg-body);
}

@media (max-width: 1200px) {
    .mayday-v2 .dashboard-sidebar {
        flex: 0 0 240px !important;
    }
}

@media (max-width: 1024px) {
    .mayday-v2.dashboard-layout {
        position: relative !important;
        top: 0 !important;
        height: auto !important;
        flex-direction: column !important;
        width: 100% !important;
        padding-top: 60px !important;
    }

    .mayday-v2 .dashboard-sidebar {
        width: 100% !important;
        flex: none !important;
        height: auto !important;
        max-height: 400px;
    }

    .mayday-main-v2 {
        height: 600px;
    }
}