/**
 * OAuth Popup and Responsive Styles
 * Browser Interface Components
 */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f3f2f1 0%, #e1dfdd 100%);
    height: 100vh;
    overflow: hidden;
}

/* Authentication Required Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f3f2f1 0%, #e1dfdd 100%);
    z-index: -1;
}

/* Authentication Required Message */
.auth-required {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #605e5c;
    font-size: 18px;
    font-weight: 500;
    display: none;
    z-index: 1;
}

.auth-required.show {
    display: block;
}

.auth-required-subtitle {
    font-size: 14px;
    font-weight: 400;
    margin-top: 8px;
    opacity: 0.8;
}

/* OAuth Popup Styles */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    backdrop-filter: blur(3px);
    animation: fadeIn 0.3s ease-out;
}

.login-box {
    background: white;
    padding: 0;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
    width: 480px;
    max-width: 90vw;
    max-height: 90vh;
    text-align: center;
    transform: scale(0.9);
    animation: popupSlideIn 0.3s ease-out forwards;
    position: relative;
    border: 1px solid #d1d1d1;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    overflow: hidden;
}

.oauth-header {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 20px 48px;
    text-align: left;
}

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

.website-icon {
    width: 32px;
    height: 32px;
    background: #0078d4;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.website-name {
    font-size: 18px;
    font-weight: 600;
    color: #212529;
}

.website-url {
    font-size: 13px;
    color: #6c757d;
}

.oauth-content {
    padding: 40px 48px 32px 48px;
}

.popup-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #605e5c;
    transition: all 0.2s ease;
}

.popup-close:hover {
    background: #f3f2f1;
    color: #323130;
}

.popup-close::before {
    content: '✕';
}

/* Microsoft Logo */
.microsoft-logo {
    width: 108px;
    height: 24px;
    margin: 0 auto 32px auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ms-logo-icon {
    width: 21px;
    height: 21px;
    margin-right: 8px;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21 21"><rect x="1" y="1" width="9" height="9" fill="%23f25022"/><rect x="11" y="1" width="9" height="9" fill="%237fba00"/><rect x="1" y="11" width="9" height="9" fill="%2300a4ef"/><rect x="11" y="11" width="9" height="9" fill="%23ffb900"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.ms-logo-text {
    font-size: 16px;
    font-weight: 600;
    color: #737373;
    font-family: 'Segoe UI', system-ui, sans-serif;
    letter-spacing: -0.01em;
}

/* OAuth Content */
.oauth-title {
    font-size: 24px;
    font-weight: 600;
    color: #323130;
    margin-bottom: 8px;
    line-height: 1.3;
}

.oauth-subtitle {
    font-size: 15px;
    color: #605e5c;
    margin-bottom: 32px;
    line-height: 1.4;
}

.oauth-description {
    font-size: 14px;
    color: #323130;
    margin-bottom: 24px;
    text-align: left;
    line-height: 1.5;
}

.permissions-list {
    text-align: left;
    margin-bottom: 32px;
}

.permission-item {
    font-size: 13px;
    color: #605e5c;
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
    line-height: 1.4;
}

.permission-item::before {
    content: '•';
    margin-right: 8px;
    color: #0078d4;
    font-weight: bold;
}

/* Buttons */
.ms-signin-btn {
    width: 100%;
    height: 44px;
    background: #0078d4;
    color: white;
    border: none;
    border-radius: 2px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 16px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ms-signin-btn:hover {
    background: #106ebe;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

.ms-signin-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-icon {
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon::before {
    content: '';
    width: 12px;
    height: 12px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23 23"><path fill="%23f3f2f1" d="M0 0h11v11H0z"/><path fill="%23ea4335" d="M0 0h11v11H0z"/><path fill="%23fbbc04" d="M11 0h12v11H11z"/><path fill="%2334a853" d="M0 11h11v12H0z"/><path fill="%234285f4" d="M11 11h12v12H11z"/></svg>') center/contain;
}

.cancel-btn {
    background: transparent;
    color: #0078d4;
    border: 1px solid #0078d4;
    height: 32px;
    padding: 0 16px;
    border-radius: 2px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cancel-btn:hover {
    background: #f3f2f1;
    border-color: #106ebe;
    color: #106ebe;
}

/* Links */
.signin-options {
    font-size: 13px;
    color: #0078d4;
    text-decoration: none;
    margin-bottom: 36px;
    display: block;
}

.signin-options:hover {
    text-decoration: underline;
}

.privacy-links {
    font-size: 11px;
    color: #605e5c;
}

.privacy-links a {
    color: #0078d4;
    text-decoration: none;
}

.privacy-links a:hover {
    text-decoration: underline;
}

/* Desktop Control Button Icons - Removed for clean macOS style */
@media screen and (min-width: 768px) {
    .control-btn.close::after,
    .control-btn.minimize::after,
    .control-btn.maximize::after {
        content: '';
    }
}

/* Browser Container - Popup Window Style */
.browser-container {
    position: fixed;
    /* Initial centered position - calculated dynamically by JS */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.75);
    transform-origin: center center; /* For initial centering */
    width: 90vw;
    height: 85vh;
    min-width: 900px;
    min-height: 700px;
    max-width: 1400px;
    max-height: 1000px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 8px 20px rgba(0, 0, 0, 0.15);
    z-index: 10500;
    display: none;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.browser-container.authenticated {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.75);
    animation: browserPopupAppear 0.4s ease-out;
}

.browser-container.maximized {
    transform: scale(1) !important;
    width: 98vw !important;
    height: 98vh !important;
    top: 1vh !important;
    left: 1vw !important;
}

/* Absolute positioned browser (after dragging/resizing) */
.browser-container.absolute-positioned {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 10500 !important;
    /* Position and transform are set dynamically by JavaScript */
}

/* Safari-specific styling */
.browser-window.safari {
    border-radius: 12px;
    overflow: hidden;
}

.browser-window.safari .title-bar {
    background: linear-gradient(135deg, #f7f7f7 0%, #e8e8e8 100%);
    border-bottom: 1px solid #d6d6d6;
    height: 44px;
}

.browser-window.safari .toolbar {
    background: linear-gradient(135deg, #f7f7f7 0%, #ebebeb 100%);
    border-bottom: 1px solid #d6d6d6;
}

.browser-window.safari .address-bar {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid #d6d6d6;
    border-radius: 8px;
    backdrop-filter: blur(20px);
}

/* Dark theme styles removed - using light theme only */

/* Mobile Safari specific styles */
@media screen and (max-width: 767px) {
    .browser-window.safari {
        border-radius: 0;
    }
    
    .browser-window.safari .title-bar {
        height: 54px;
        background: linear-gradient(135deg, #f7f7f7 0%, #e8e8e8 100%);
    }
    
    .browser-window.safari .toolbar {
        height: 60px;
        background: linear-gradient(135deg, #f7f7f7 0%, #ebebeb 100%);
        padding: 8px 20px;
    }
    
    .browser-window.safari .address-bar {
        height: 36px;
        border-radius: 18px;
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(20px);
        border: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    /* Dark theme styles removed - using light theme only */
}

/* Chrome-specific styling */
.browser-window.chrome {
    border-radius: 8px;
}

.browser-window.chrome .title-bar {
    background: linear-gradient(135deg, #f1f3f4 0%, #dadce0 100%);
    border-bottom: 1px solid #dadce0;
}

.browser-window.chrome .toolbar {
    background: linear-gradient(135deg, #f1f3f4 0%, #e8eaed 100%);
    border-bottom: 1px solid #dadce0;
}

.browser-window.chrome .address-bar {
    background: #ffffff;
    border: 1px solid #dadce0;
    border-radius: 24px;
    color: #202124;
}

/* Chrome dark theme styles removed - using light theme only */

/* Browser-Specific Icons - Now using IMG tags instead of CSS backgrounds */
.browser-icon { 
    width: 16px;
    height: 16px;
    margin-right: 8px;
    display: inline-block;
    vertical-align: middle;
    border-radius: 3px;
}

/* Remove old CSS-based icon styles */
.browser-icon-chrome,
.browser-icon-firefox,
.browser-icon-edge,
.browser-icon-safari {
    background: none;
    border: none;
    position: relative;
}

.browser-icon-chrome::after,
.browser-icon-firefox::before,
.browser-icon-edge::after,
.browser-icon-safari::before,
.browser-icon-safari::after {
    display: none;
}

/* Dark theme styles removed - using light theme only */

/* OS-Specific Styling */

/* Windows OS styling - Angular design with flat elements */
.browser-window.windows {
    border-radius: 0px; /* Windows uses sharp corners */
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.browser-window.windows .title-bar {
    background: #f3f3f3;
    border-bottom: 1px solid #d1d1d1;
    border-radius: 0; /* No rounded corners on Windows */
    height: 32px; /* Standard Windows title bar height */
    padding: 0 16px;
}

.browser-window.windows .toolbar {
    background: #ffffff;
    border-bottom: 1px solid #e1e1e1;
    border-radius: 0;
    padding: 8px 12px;
}

.browser-window.windows .address-bar {
    background: #ffffff;
    border: 1px solid #d1d1d1;
    border-radius: 2px; /* Minimal border radius on Windows */
    height: 28px;
    font-size: 14px;
    font-family: 'Segoe UI', sans-serif;
}

/* Windows Chrome specific */
.browser-window.windows.chrome .title-bar {
    background: #ffffff;
    border-bottom: 1px solid #dadce0;
}

.browser-window.windows.chrome .toolbar {
    background: #f8f9fa;
}

/* Windows Edge specific */
.browser-window.windows.edge .title-bar {
    background: #ffffff;
    border-bottom: 1px solid #e1e1e1;
}

.browser-window.windows.edge .toolbar {
    background: #f3f2f1;
}

/* Windows Firefox specific */
.browser-window.windows.firefox .title-bar {
    background: #f9f9fa;
    border-bottom: 1px solid #d7d7db;
}

.browser-window.windows.firefox .toolbar {
    background: #ffffff;
}

/* Mac OS styling - Rounded design with blur effects */
.browser-window.mac {
    border-radius: 12px; /* Mac uses rounded corners */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.browser-window.mac .title-bar {
    background: linear-gradient(135deg, #f7f7f7 0%, #e8e8e8 100%);
    border-bottom: 1px solid #d6d6d6;
    border-radius: 12px 12px 0 0; /* Rounded top corners */
    height: 44px; /* macOS standard height */
    padding: 0 20px;
}

.browser-window.mac .toolbar {
    background: linear-gradient(135deg, #f7f7f7 0%, #ebebeb 100%);
    border-bottom: 1px solid #d6d6d6;
    border-radius: 0;
    padding: 10px 16px;
}

.browser-window.mac .address-bar {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid #d6d6d6;
    border-radius: 8px; /* Mac rounded corners */
    backdrop-filter: blur(20px);
    height: 32px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Mac Safari specific - inherit existing Safari styles but ensure Mac styling */
.browser-window.mac.safari .title-bar {
    background: linear-gradient(135deg, #f7f7f7 0%, #e8e8e8 100%);
    border-bottom: 1px solid #d6d6d6;
    height: 44px;
}

/* Mac Chrome specific */
.browser-window.mac.chrome .title-bar {
    background: linear-gradient(135deg, #f1f3f4 0%, #e8eaed 100%);
    border-bottom: 1px solid #dadce0;
}

/* Mac Edge specific */
.browser-window.mac.edge .title-bar {
    background: linear-gradient(135deg, #f3f2f1 0%, #e1dfdd 100%);
    border-bottom: 1px solid #d2d0ce;
}

/* Mac Firefox specific */
.browser-window.mac.firefox .title-bar {
    background: linear-gradient(135deg, #f9f9fa 0%, #ededf0 100%);
    border-bottom: 1px solid #d7d7db;
}

/* Windows Title Bar Layout */
.browser-window.windows .title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.browser-window.windows .window-controls {
    display: flex;
    gap: 0; /* No gap between Windows buttons */
    order: 2; /* Ensure controls are on the right */
}

/* Reorder Windows buttons: Minimize (2), Maximize (3), Close (1) - left to right */
.browser-window.windows .control-btn.minimize {
    order: 1;
}

.browser-window.windows .control-btn.maximize {
    order: 2;
}

.browser-window.windows .control-btn.close {
    order: 3;
}

.browser-window.windows .window-title {
    order: 1; /* Title on the left */
}

/* Windows Control Buttons - Override Mac-style circular buttons */
.browser-window.windows .control-btn {
    width: 46px !important;
    height: 32px !important;
    min-width: 46px;
    min-height: 32px;
    border-radius: 0 !important; /* Square corners for Windows */
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    position: relative;
    transition: background-color 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.browser-window.windows .control-btn:hover {
    transform: none !important; /* Remove Mac-style scaling */
    box-shadow: none !important;
}

.browser-window.windows .control-btn.minimize {
    background: transparent !important;
}

.browser-window.windows .control-btn.minimize:hover {
    background: rgba(0, 0, 0, 0.1) !important;
}

.browser-window.windows .control-btn.maximize {
    background: transparent !important;
}

.browser-window.windows .control-btn.maximize:hover {
    background: rgba(0, 0, 0, 0.1) !important;
}

.browser-window.windows .control-btn.close {
    background: transparent !important;
}

.browser-window.windows .control-btn.close:hover {
    background: #e81123 !important;
}

/* Windows Control Button Icons */
.browser-window.windows .control-btn.minimize::after {
    content: '';
    width: 10px;
    height: 1px;
    background: #000;
    position: absolute;
}

.browser-window.windows .control-btn.minimize:hover::after {
    background: #000;
}

.browser-window.windows .control-btn.maximize::after {
    content: '';
    width: 10px;
    height: 10px;
    border: 1px solid #000;
    background: transparent;
    position: absolute;
}

.browser-window.windows .control-btn.maximize:hover::after {
    border-color: #000;
}

.browser-window.windows .control-btn.close::after {
    content: '×';
    font-size: 16px;
    font-weight: normal;
    color: #000;
    line-height: 1;
    position: absolute;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.browser-window.windows .control-btn.close:hover::after {
    color: #fff;
}

/* Windows Control Button Active States */
.browser-window.windows .control-btn:active {
    transform: none !important;
    box-shadow: none !important;
}

.browser-window.windows .control-btn.minimize:active {
    background: rgba(0, 0, 0, 0.2) !important;
}

.browser-window.windows .control-btn.maximize:active {
    background: rgba(0, 0, 0, 0.2) !important;
}

.browser-window.windows .control-btn.close:active {
    background: #c50e1f !important;
}

/* Mac Title Bar Layout - Traditional Mac style with controls on left */
.browser-window.mac .title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.browser-window.mac .window-controls {
    order: 1; /* Controls on the left for Mac */
    gap: 8px; /* Mac-style gap between buttons */
}

.browser-window.mac .window-title {
    order: 2; /* Title on the right for Mac */
}

/* Keep Mac button order as is: Close, Minimize, Maximize */
.browser-window.mac .control-btn.close {
    order: 1;
}

.browser-window.mac .control-btn.minimize {
    order: 2;
}

.browser-window.mac .control-btn.maximize {
    order: 3;
}

/* Dark theme Windows controls removed - using light theme only */

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popupSlideIn {
    from { 
        transform: scale(0.9) translateY(-20px);
        opacity: 0;
    }
    to { 
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes popupSlideOut {
    from { 
        transform: scale(1) translateY(0);
        opacity: 1;
    }
    to { 
        transform: scale(0.95) translateY(-10px);
        opacity: 0;
    }
}

@keyframes browserPopupAppear {
    from {
        transform: translate(-50%, -50%) scale(0.4);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(0.75);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.login-container.closing {
    animation: fadeOut 0.2s ease-out forwards;
}

.login-container.closing .login-box {
    animation: popupSlideOut 0.2s ease-out forwards;
}

.login-container.background {
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.login-container.background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    z-index: 1;
}

/* =================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ================================= */

/* Mobile Devices (320px to 767px) */
@media screen and (max-width: 767px) {
    body {
        padding: 0;
        margin: 0;
    }
    
    /* Auth Required Message - Mobile */
    .auth-required {
        font-size: 16px;
        padding: 20px;
        max-width: 90%;
    }
    
    .auth-required-subtitle {
        font-size: 12px;
    }
    
    /* Login Container - Mobile */
    .login-container {
        padding: 0;
        align-items: stretch;
    }
    
    .login-box {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        transform: translateY(100%);
        transition: transform 0.3s ease-out;
    }
    
    .login-box.show {
        transform: translateY(0);
    }
    
    .oauth-header {
        padding: 20px 24px;
        border-bottom: 2px solid #e9ecef;
    }
    
    .website-name {
        font-size: 18px;
        font-weight: 700;
    }
    
    .website-url {
        font-size: 14px;
    }
    
    .oauth-content {
        padding: 32px 24px 24px 24px;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    .oauth-title {
        font-size: 20px;
        margin-bottom: 6px;
    }
    
    .oauth-subtitle {
        font-size: 14px;
        margin-bottom: 24px;
    }
    
    .oauth-description {
        font-size: 13px;
        margin-bottom: 20px;
    }
    
    .permissions-list {
        margin-bottom: 24px;
    }
    
    .permission-item {
        font-size: 12px;
        margin-bottom: 6px;
    }
    
    .ms-signin-btn {
        height: 48px;
        font-size: 16px;
        margin-bottom: 12px;
        border-radius: 6px;
    }
    
    .popup-close {
        top: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        background: rgba(0, 0, 0, 0.1);
        border-radius: 50%;
        z-index: 1001;
    }
    
    .popup-close:hover {
        background: rgba(0, 0, 0, 0.2);
    }
    
    /* Browser Container - Mobile */
    .browser-container {
        top: 0;
        left: 0;
        transform: none;
        width: 100vw;
        height: 100vh;
        min-width: auto;
        min-height: auto;
        max-width: none;
        max-height: none;
        border-radius: 0;
        box-shadow: none;
    }
    
    .browser-container.authenticated {
        transform: none;
    }
    
    .browser-container.maximized {
        transform: none !important;
    }
    
    /* Browser Window - Mobile */
    .browser-window {
        border: none;
        border-radius: 0;
    }
    
    .title-bar {
        height: 54px;
        padding: 0 20px;
        background: linear-gradient(135deg, #f9f9fa 0%, #e9ecef 100%);
        border-bottom: 2px solid #dee2e6;
    }
    
    .window-title {
        font-size: 16px;
        font-weight: 600;
        color: #495057;
    }
    
    .window-controls {
        gap: 8px;
    }
    
    .control-btn {
        width: 24px !important;
        height: 24px !important;
        min-width: 24px;
        min-height: 24px;
        border-radius: 50%;
        border: 2px solid rgba(255, 255, 255, 0.9);
        margin: 0;
        cursor: pointer;
        transition: all 0.2s ease;
        position: relative;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .control-btn.close {
        background: #ff5f57;
        border-color: #ff3b30;
    }
    
    .control-btn.minimize {
        background: #ffbd2e;
        border-color: #ff9500;
    }
    
    .control-btn.maximize {
        background: #28ca42;
        border-color: #30d158;
    }
    
    .control-btn:hover,
    .control-btn:focus {
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }
    
    .control-btn:active {
        transform: scale(0.95);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    }
    
    /* Control buttons without icons for clean macOS style */
    .control-btn.close::after,
    .control-btn.minimize::after,
    .control-btn.maximize::after {
        content: '';
    }
    
    .toolbar {
        height: 60px;
        padding: 8px 20px;
        flex-wrap: wrap;
        gap: 12px;
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        border-bottom: 1px solid #dee2e6;
    }
    
    .nav-buttons {
        order: 2;
        flex: 0 0 auto;
        gap: 8px;
    }
    
    .nav-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.9);
        border: 2px solid #dee2e6;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        transition: all 0.2s ease;
    }
    
    .nav-btn:hover,
    .nav-btn:focus {
        transform: scale(1.05);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
        border-color: #0078d4;
    }
    
    .nav-btn:active {
        transform: scale(0.95);
    }
    
    .address-bar {
        order: 1;
        flex: 1 1 100%;
        height: 48px;
        border-radius: 24px;
        padding: 0 20px;
        font-size: 16px;
        margin-bottom: 8px;
        border: 2px solid #dee2e6;
        background: rgba(255, 255, 255, 0.95);
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
        transition: all 0.2s ease;
    }
    
    .address-bar:focus {
        border-color: #0078d4;
        box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.1);
    }
    
    .browser-menu {
        order: 3;
        gap: 8px;
    }
    
    .menu-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.9);
        border: 2px solid #dee2e6;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        transition: all 0.2s ease;
    }
    
    .menu-btn:hover,
    .menu-btn:focus {
        transform: scale(1.05);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
        border-color: #0078d4;
    }
    
    .menu-btn:active {
        transform: scale(0.95);
    }
    
    /* Content Area - Mobile */
    .content-area {
        flex: 1;
        background: #ffffff;
        position: relative;
        overflow: hidden;
    }
    
    .browser-iframe {
        width: 100%;
        height: 100%;
        border: none;
        background: #fff;
    }
}

/* Small Tablets (768px to 1023px) */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    /* Login Container - Tablet */
    .login-container {
        padding: 20px;
    }
    
    .login-box {
        width: 500px;
        max-width: 85vw;
    }
    
    .oauth-content {
        padding: 36px 40px 28px 40px;
    }
    
    /* Browser Container - Tablet */
    .browser-container {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.85);
        width: 95vw;
        height: 90vh;
        min-width: 700px;
        min-height: 600px;
        max-width: 1200px;
        max-height: 900px;
    }
    
    .browser-container.authenticated {
        transform: translate(-50%, -50%) scale(0.85);
    }
    
    .browser-container.maximized {
        transform: translate(-50%, -50%) scale(1) !important;
        width: 98vw;
        height: 98vh;
    }
    
    /* Tablet Control Buttons */
    .window-controls {
        gap: 10px;
    }
    
    .control-btn {
        width: 18px !important;
        height: 18px !important;
        min-width: 18px;
        min-height: 18px;
        border: 1.5px solid rgba(255, 255, 255, 0.9);
    }
    
    .control-btn.close::after,
    .control-btn.minimize::after,
    .control-btn.maximize::after {
        content: '';
    }
    
    /* Hide zoom controls on tablets - they're not needed */
    .zoom-out-btn,
    .zoom-in-btn {
        display: none;
    }
    
    /* Adjust toolbar for tablet */
    .toolbar {
        height: 45px;
        padding: 0 15px;
    }
    
    .nav-btn {
        width: 36px;
        height: 36px;
        border-radius: 6px;
    }
    
    .address-bar {
        height: 36px;
        font-size: 15px;
    }
    
    .menu-btn {
        width: 36px;
        height: 36px;
        border-radius: 6px;
    }
    
    /* Tablet-optimized title bar */
    .title-bar {
        height: 40px;
        padding: 0 16px;
    }
    
    .window-title {
        font-size: 15px;
        font-weight: 500;
    }
    
    .browser-icon {
        width: 18px;
        height: 18px;
        margin-right: 10px;
    }
}

/* Large Tablets and Small Desktops (1024px to 1439px) */
@media screen and (min-width: 1024px) and (max-width: 1439px) {
    .browser-container {
        top: 47%;
        left: 52%;
        transform: translate(-50%, -50%) scale(0.8);
        width: 88vw;
        height: 82vh;
        min-width: 800px;
        min-height: 650px;
        max-width: 1300px;
        max-height: 950px;
    }
    
    .browser-container.authenticated {
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* Large Desktops (1440px+) */
@media screen and (min-width: 1440px) {
    .browser-container {
        top: 45%;
        left: 55%;
        transform: translate(-50%, -50%) scale(0.75);
        width: 85vw;
        height: 80vh;
        min-width: 900px;
        min-height: 700px;
        max-width: 1400px;
        max-height: 1000px;
    }
    
    .browser-container.authenticated {
        transform: translate(-50%, -50%) scale(0.75);
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .nav-btn,
    .menu-btn,
    .ms-signin-btn,
    .cancel-btn,
    .popup-close {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Control buttons should stay smaller even on touch devices */
    .control-btn {
        min-height: 24px !important;
        min-width: 24px !important;
    }
    
    .nav-btn:hover,
    .menu-btn:hover,
    .popup-close:hover,
    .cancel-btn:hover {
        background: rgba(0,0,0,0.15);
    }
    
    .ms-signin-btn:hover {
        background: #0078d4;
        transform: none;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    /* Touch feedback for dragging */
    .browser-container .title-bar:active {
        background: rgba(0, 0, 0, 0.05);
        transform: scale(0.98);
        transition: all 0.1s ease;
    }
    
    /* Touch feedback for resize handles */
    .browser-container .ui-resizable-handle:active {
        background: rgba(0, 123, 255, 0.2);
        transition: background 0.1s ease;
    }
}

/* Landscape Mobile Devices */
@media screen and (max-width: 767px) and (orientation: landscape) {
    .login-container {
        align-items: center;
    }
    
    .login-box {
        max-height: 90vh;
        border-radius: 12px;
        transform: scale(0.95);
    }
    
    .oauth-content {
        padding: 20px;
    }
    
    .oauth-title {
        font-size: 18px;
    }
    
    .oauth-subtitle {
        font-size: 13px;
        margin-bottom: 16px;
    }
    
    .permissions-list {
        margin-bottom: 16px;
    }
    
    .ms-signin-btn {
        height: 40px;
        font-size: 14px;
    }
    
    .browser-container {
        height: 100vh;
    }
    
    .toolbar {
        height: 44px;
        flex-wrap: nowrap;
    }
    
    .address-bar {
        flex: 1 1 auto;
        margin-bottom: 0;
    }
}

/* High DPI Screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .browser-window {
        border: 0.5px solid #d6d6d6;
    }
    
    .control-btn {
        border: 0.5px solid rgba(0,0,0,0.1);
    }
    
    .nav-btn, .menu-btn {
        border: 0.5px solid transparent;
    }
}

/* ================================
   DRAG AND RESIZE FUNCTIONALITY
   ================================ */

/* Disable text selection during drag/resize */
body.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Make title bar cursor indicate draggability */
.browser-container .title-bar {
    cursor: move;
    touch-action: none; /* Prevent default touch behaviors */
    user-select: none; /* Prevent text selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.browser-container .title-bar .window-title {
    cursor: move;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.browser-container .title-bar .control-btn {
    cursor: pointer;
    touch-action: manipulation; /* Allow normal touch for buttons */
}

/* jQuery UI Resize Handle Customization */
.browser-container .ui-resizable-handle {
    background: transparent;
    border: none;
    touch-action: none; /* Prevent default touch behaviors */
}

.browser-container .ui-resizable-n,
.browser-container .ui-resizable-s {
    height: 8px; /* Larger for touch */
    cursor: ns-resize;
}

.browser-container .ui-resizable-e,
.browser-container .ui-resizable-w {
    width: 8px; /* Larger for touch */
    cursor: ew-resize;
}

.browser-container .ui-resizable-ne,
.browser-container .ui-resizable-nw,
.browser-container .ui-resizable-se,
.browser-container .ui-resizable-sw {
    width: 16px; /* Much larger for touch */
    height: 16px;
}

/* Touch-friendly resize handles on mobile */
@media (max-width: 1023px) {
    .browser-container .ui-resizable-n,
    .browser-container .ui-resizable-s {
        height: 12px; /* Even larger on mobile */
    }
    
    .browser-container .ui-resizable-e,
    .browser-container .ui-resizable-w {
        width: 12px;
    }
    
    .browser-container .ui-resizable-ne,
    .browser-container .ui-resizable-nw,
    .browser-container .ui-resizable-se,
    .browser-container .ui-resizable-sw {
        width: 20px;
        height: 20px;
    }
}

.browser-container .ui-resizable-ne {
    cursor: ne-resize;
    top: -4px;
    right: -4px;
}

.browser-container .ui-resizable-nw {
    cursor: nw-resize;
    top: -4px;
    left: -4px;
}

.browser-container .ui-resizable-se {
    cursor: se-resize;
    bottom: -4px;
    right: -4px;
}

.browser-container .ui-resizable-sw {
    cursor: sw-resize;
    bottom: -4px;
    left: -4px;
}

.browser-container .ui-resizable-n {
    top: -2px;
    left: 0;
    width: 100%;
}

.browser-container .ui-resizable-s {
    bottom: -2px;
    left: 0;
    width: 100%;
}

.browser-container .ui-resizable-e {
    right: -2px;
    top: 0;
    height: 100%;
}

.browser-container .ui-resizable-w {
    left: -2px;
    top: 0;
    height: 100%;
}

/* Add a subtle resize indicator in the bottom-right corner */
.browser-container::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: linear-gradient(
        -45deg,
        transparent 0%,
        transparent 25%,
        rgba(0,0,0,0.1) 25%,
        rgba(0,0,0,0.1) 50%,
        transparent 50%,
        transparent 75%,
        rgba(0,0,0,0.1) 75%
    );
    background-size: 4px 4px;
    pointer-events: none;
    z-index: 1001;
}

/* Ensure browser container is positioned for dragging */
.browser-container {
    position: fixed !important;
}

/* Improve dragging performance */
.browser-container.ui-draggable-dragging {
    opacity: 0.9;
    z-index: 10600 !important;
}

.browser-container.ui-resizable-resizing {
    opacity: 0.9;
}

/* When dragging, use top-left origin for scale to prevent positioning issues */
.browser-container.dragging {
    transform-origin: top left !important;
}

/* When in absolute positioning mode, override any transform