/* ==========================================================================
   MAHAGA ONE - Shortlink Portal CSS
   Design: Modern, Premium Corporate Portal matching Reference Image
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    /* Color Palette */
    --mahaga-green-dark: #0A3C23;
    --mahaga-green-primary: #388E3C;
    --mahaga-green-vibrant: #52B743;
    --mahaga-green-light: #80C242;
    --mahaga-green-tint: #F2F9F3;

    --bg-page: #F6F9F6;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;

    --card-bg: #FFFFFF;
    --card-shadow: 0 12px 32px -4px rgba(10, 60, 35, 0.08), 0 4px 12px -2px rgba(0, 0, 0, 0.03);
    --card-shadow-hover: 0 24px 48px -8px rgba(82, 183, 67, 0.22), 0 8px 16px -4px rgba(10, 60, 35, 0.1);

    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Reset & Global Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    padding: 8px 20px 10px;
    -webkit-font-smoothing: antialiased;
}

/* Background Graphical Overlay (Corner Waves + Halftone Dots) */
.bg-decorations {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

/* Corner Green Waves - with floating animation */
.bg-decorations .wave-top-left {
    position: absolute;
    top: -40px;
    left: -40px;
    width: 350px;
    height: 350px;
    background: radial-gradient(circle at 0 0, rgba(82, 183, 67, 0.45) 0%, rgba(128, 194, 66, 0.2) 40%, transparent 65%);
    border-radius: 50%;
    filter: blur(18px);
    animation: floatWaveTL 8s ease-in-out infinite;
}

.bg-decorations .wave-top-right {
    position: absolute;
    top: -30px;
    right: -30px;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle at 100% 0, rgba(82, 183, 67, 0.4) 0%, rgba(10, 60, 35, 0.15) 45%, transparent 65%);
    border-radius: 50%;
    filter: blur(20px);
    animation: floatWaveTR 10s ease-in-out infinite;
}

.bg-decorations .wave-bottom-left {
    position: absolute;
    bottom: -50px;
    left: -50px;
    width: 420px;
    height: 420px;
    background: radial-gradient(circle at 0 100%, rgba(82, 183, 67, 0.45) 0%, rgba(128, 194, 66, 0.18) 45%, transparent 65%);
    border-radius: 50%;
    filter: blur(18px);
    animation: floatWaveBL 9s ease-in-out infinite;
}

.bg-decorations .wave-bottom-right {
    position: absolute;
    bottom: -40px;
    right: -40px;
    width: 450px;
    height: 450px;
    background: radial-gradient(circle at 100% 100%, rgba(10, 60, 35, 0.35) 0%, rgba(82, 183, 67, 0.25) 45%, transparent 65%);
    border-radius: 50%;
    filter: blur(20px);
    animation: floatWaveBR 11s ease-in-out infinite;
}

/* Halftone Dot Grids in Corners */
.halftone-corner {
    position: absolute;
    width: 250px;
    height: 250px;
    background-image: radial-gradient(circle, rgba(56, 142, 60, 0.55) 2.5px, transparent 3px);
    background-size: 16px 16px;
    opacity: 1;
}

.halftone-tl {
    top: 0;
    left: 0;
    mask-image: radial-gradient(ellipse at 0% 0%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 40%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at 0% 0%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 40%, transparent 70%);
    animation: pulseDots 6s ease-in-out infinite;
}

.halftone-tr {
    top: 0;
    right: 0;
    mask-image: radial-gradient(ellipse at 100% 0%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 40%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at 100% 0%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 40%, transparent 70%);
    animation: pulseDots 7s ease-in-out infinite 1s;
}

.halftone-bl {
    bottom: 0;
    left: 0;
    mask-image: radial-gradient(ellipse at 0% 100%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 40%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at 0% 100%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 40%, transparent 70%);
    animation: pulseDots 8s ease-in-out infinite 0.5s;
}

.halftone-br {
    bottom: 0;
    right: 0;
    mask-image: radial-gradient(ellipse at 100% 100%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 40%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at 100% 100%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 40%, transparent 70%);
    animation: pulseDots 6.5s ease-in-out infinite 1.5s;
}

/* Wave floating animations */
@keyframes floatWaveTL {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(12px, 10px) scale(1.05);
    }
}

@keyframes floatWaveTR {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(-10px, 12px) scale(1.06);
    }
}

@keyframes floatWaveBL {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(10px, -12px) scale(1.04);
    }
}

@keyframes floatWaveBR {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(-12px, -10px) scale(1.05);
    }
}

/* Halftone dot pulsing animation */
@keyframes pulseDots {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.04);
    }
}

/* Main Container */
.portal-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1180px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
}

/* Header Section */
.portal-header {
    text-align: center;
    margin-bottom: -30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 1;
    width: 100%;
}

.brand-banner {
    width: 100%;
    max-width: 820px;
    height: auto;
    max-height: min(380px, 45vh);
    object-fit: contain;
    animation: logoBreathe 4s ease-in-out infinite;
    transition: transform var(--transition-bounce), filter var(--transition-normal);
}

.brand-banner:hover {
    transform: scale(1.025);
    animation-play-state: paused;
}

@keyframes logoBreathe {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

/* Portal Grid Layout */
.apps-grid-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
}

/* Row 1: 3 Columns */
.grid-row-top {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    width: 100%;
}

/* Row 2: 2 Columns Centered */
.grid-row-bottom {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    width: calc(66.66% + 8px);
    /* Exact alignment with top row cards */
    margin: 0 auto;
}

/* App Card Component */
.app-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 10px 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(226, 232, 240, 0.8);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition-bounce), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.app-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3.5px;
    background: linear-gradient(90deg, var(--mahaga-green-vibrant), var(--mahaga-green-light));
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.app-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--card-shadow-hover);
    border-color: rgba(82, 183, 67, 0.3);
}

.app-card:hover::before {
    opacity: 1;
}

/* Icon Container */
.icon-badge {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    position: relative;
    flex-shrink: 0;
    transition: transform var(--transition-bounce), background-color var(--transition-normal);
}

.icon-badge svg {
    width: 32px;
    height: 32px;
    transition: transform var(--transition-bounce);
}

.icon-badge .icon-img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 50%;
    transition: transform var(--transition-bounce);
}

.app-card:hover .icon-badge {
    transform: scale(1.08);
}

.app-card:hover .icon-badge svg {
    transform: scale(1.06) rotate(-3deg);
}

/* Card Content */
.card-title {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 2px;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 4px;
    line-height: 1.2;
}

.title-prefix {
    color: var(--mahaga-green-vibrant);
}

.title-suffix {
    color: var(--mahaga-green-dark);
}

.card-description {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.35;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 230px;
}

/* Card Links */
.card-links {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Action Button (Green Circle with Right Arrow) */
.card-action-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--mahaga-green-vibrant);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    box-shadow: 0 3px 8px rgba(82, 183, 67, 0.35);
    flex-shrink: 0;
    transition: transform var(--transition-bounce), background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card-action-btn svg {
    width: 14px;
    height: 14px;
    stroke: #FFFFFF;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    transition: transform var(--transition-normal);
}

.app-card:hover .card-action-btn {
    background: #46A338;
    transform: scale(1.1);
    box-shadow: 0 5px 14px rgba(82, 183, 67, 0.5);
}

.app-card:hover .card-action-btn svg {
    transform: translateX(3px);
}

.card-secondary-link {
    color: var(--mahaga-green-primary);
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.card-secondary-link:hover {
    text-decoration: underline;
}

/* Admin / Settings Trigger Icon */
.admin-settings-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    z-index: 100;
    transition: transform var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast);
}

.admin-settings-btn:hover {
    transform: rotate(45deg) scale(1.08);
    color: var(--mahaga-green-vibrant);
    border-color: var(--mahaga-green-vibrant);
}

/* Modal for Editing Target URLs */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: #FFFFFF;
    border-radius: 20px;
    width: 100%;
    max-width: 580px;
    padding: 32px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-box {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #F1F5F9;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--mahaga-green-dark);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

.url-input-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 6px;
}

.url-input-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.url-input-item label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.url-input-item input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #CBD5E1;
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.url-input-item input:focus {
    outline: none;
    border-color: var(--mahaga-green-vibrant);
    box-shadow: 0 0 0 3px rgba(82, 183, 67, 0.15);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-secondary {
    padding: 10px 18px;
    border-radius: 10px;
    background: #F1F5F9;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #E2E8F0;
}

.btn-primary {
    padding: 10px 22px;
    border-radius: 10px;
    background: var(--mahaga-green-vibrant);
    border: none;
    color: #FFFFFF;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(82, 183, 67, 0.3);
    transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
    background: #459E38;
}

.btn-primary:active {
    transform: scale(0.98);
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1E293B;
    color: #FFFFFF;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    pointer-events: none;
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Footer Section */
.portal-footer {
    margin-top: auto;
    padding-bottom: 8px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-align: center;
    z-index: 1;
    flex-shrink: 0;
}

.portal-footer span.brand-credit {
    color: var(--mahaga-green-vibrant);
    font-weight: 700;
}

/* Responsive Media Queries */
@media (max-width: 992px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
    }

    .grid-row-top,
    .grid-row-bottom {
        grid-template-columns: repeat(2, 1fr);
        width: 100%;
    }
}

@media (max-height: 650px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
        padding: 16px;
    }
}

@media (max-width: 640px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
        padding: 24px 16px 16px;
    }

    .brand-banner {
        max-width: 100%;
        padding: 0 10px;
    }

    .grid-row-top,
    .grid-row-bottom {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .app-card {
        padding: 20px 16px;
    }

    .icon-badge {
        width: 64px;
        height: 64px;
    }

    .icon-badge svg {
        width: 36px;
        height: 36px;
    }

    .bg-decorations .halftone-left,
    .bg-decorations .halftone-right {
        display: none;
    }
}